Javascript 为什么我的.vue组件未定义?
我正在使用Javascript 为什么我的.vue组件未定义?,javascript,vue.js,babeljs,parceljs,Javascript,Vue.js,Babeljs,Parceljs,我正在使用包插件vue从文件中编译尽可能最简单的.vue组件 编译运行,没有错误,但在我的浏览器中显示一个空白页,没有写入内容。我可以在main.js文件中看到import.vue组件在运行时未定义。这是为什么 main.js import Vue from '../node_modules/vue/dist/vue'; import { Welcome } from './app/widgets/welcome/welcome.vue'; //this is undefined at run
包插件vue
从文件中编译尽可能最简单的.vue组件
编译运行,没有错误,但在我的浏览器中显示一个空白页,没有写入内容。我可以在main.js文件中看到import.vue组件在运行时未定义。这是为什么
main.js
import Vue from '../node_modules/vue/dist/vue';
import { Welcome } from './app/widgets/welcome/welcome.vue'; //this is undefined at runtime, but doesn't error
window.onload = startVue;
function startVue()
{
new Vue({
'el': '#app',
'template': Welcome,
'components': { Welcome }
});
}
欢迎光临
<template>
<div>
<h1>Welcome</h1>
</div>
</template>
<script>
export default
{
components: {}
}
</script>
<style>
</style>
要进行编译,我正在运行
/node\u modules/.bin/parcel index.html
在Welcome.vue
组件中没有名为Welcome
的导出,因此无法使用大括号语法导入它。导入操作不应使用大括号:
import Welcome from./app/widgets/Welcome/Welcome.vue'代码>
{
"main": "index.js",
"devDependencies": {
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"css-loader": "^0.28.7",
"eslint": "^4.14.0",
"parcel-bundler": "^1.3.1",
"parcel-plugin-vue": "^1.4.0"
},
"dependencies": {
"vue": "^2.5.13",
"vue-material": "^1.0.0-beta-7",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
}
}