简体   繁体   English

“未捕获的ReferenceError:vue未定义”

[英]“Uncaught ReferenceError: vue is not defined”

Hi I'm supposed to make a website for school using vue, 嗨,我应该用vue建立一个学校网站,

I've included vue in the head of the html using: 我在html的头部包含了vue:

<script src="https://unpkg.com/vue"></script>

When I try to create a new vue (as a script in html and as a .js file): 当我尝试创建一个新的vue(作为html脚本和.js文件):

var vuetop = new vue({
    el: '#vuetop',
        data: {
            dat: null
        },
        created: function() {
            fetch("/data/topnews.json")
                .then(r => r.json())
                .then(tdat => {
                    this.dat = tdat;
                })
        }
    })

I always get the error "Uncaught ReferenceError: vue is not defined" 我总是得到错误“Uncaught ReferenceError:vue is not defined”

它应该是Vue而不是vue ,第一个字母V应该是一个大写字母。

You can see the oficial vue example in this link ( https://gist.githubusercontent.com/chrisvfritz/7f8d7d63000b48493c336e48b3db3e52/raw/ed60c4e5d5c6fec48b0921edaed0cb60be30e87c/index.html ) 你可以在这个链接中看到官方的vue示例( https://gist.githubusercontent.com/chrisvfritz/7f8d7d63000b48493c336e48b3db3e52/raw/ed60c4e5d5c6fec48b0921edaed0cb60be30e87c/index.html

But maybe only changing vue to Vue like the other answers will solve your problem. 但也许只有像其他答案一样将vue改为Vue才能解决你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM