Javascript 未捕获引用错误:.Vue文件中未定义Vue
您好,我是vue新手,在全球范围内安装了vue cli,不知道为什么会出现此错误:Javascript 未捕获引用错误:.Vue文件中未定义Vue,javascript,webpack,vue.js,Javascript,Webpack,Vue.js,您好,我是vue新手,在全球范围内安装了vue cli,不知道为什么会出现此错误: Uncaught ReferenceError: Vue is not defined at eval (Hello.vue?13ca:73) at Object.<anonymous> (main.js:1061) at __webpack_require__ (main.js:679) at fn (main.js:89) at eval (Hello.vue?549c:1) at Object.
Uncaught ReferenceError: Vue is not defined
at eval (Hello.vue?13ca:73)
at Object.<anonymous> (main.js:1061)
at __webpack_require__ (main.js:679)
at fn (main.js:89)
at eval (Hello.vue?549c:1)
at Object.<anonymous> (main.js:1049)
at __webpack_require__ (main.js:679)
at fn (main.js:89)
at eval (index.js?fc04:1)
at Object.<anonymous> (main.js:1035)
错误是因为Hello.vue文件中的这一部分,当我删除这一部分时,一切似乎都正常:
<script>
var nav = new Vue({
el: '#loginButtons',
methods: {
open: function(which, e) {
// Prevents clicking the link from doing anything
e.preventDefault();
}
}
});
</script>
var nav=新的Vue({
el:'登录按钮',
方法:{
打开:功能(其中,e){
//阻止单击链接执行任何操作
e、 预防默认值();
}
}
});
单个文件组件的
标记必须导出通常传递给新Vue()构造函数的对象。您也不需要el
属性,因为Vue将使用
作为根元素
<script>
export {
methods: {
open: function(which, e) {
// Prevents clicking the link from doing anything
e.preventDefault();
}
}
};
</script>
出口{
方法:{
打开:功能(其中,e){
//阻止单击链接执行任何操作
e、 预防默认值();
}
}
};
单个文件组件的
标记必须导出通常传递给新Vue()构造函数的对象。您也不需要el
属性,因为Vue将使用
作为根元素
<script>
export {
methods: {
open: function(which, e) {
// Prevents clicking the link from doing anything
e.preventDefault();
}
}
};
</script>
出口{
方法:{
打开:功能(其中,e){
//阻止单击链接执行任何操作
e、 预防默认值();
}
}
};
Hello.vue
中不应包含类似于新vue
的内容。这是一个组件。请参阅示例。好的,谢谢,这是一个愚蠢的错误…Hello.vue
中不应该包含类似于new vue
的内容。这是一个组件。请看示例。好的,谢谢你,这是一个愚蠢的错误。。。
<script>
export {
methods: {
open: function(which, e) {
// Prevents clicking the link from doing anything
e.preventDefault();
}
}
};
</script>