我已经安装了名为 element 的 Vue.js 框架但我收到此错误。
我正在导入我需要的所有内容到index.html和Reviews.vue文件,其中仅包含:
<template>
<div id="app">
<el-button type="primary" round>Primary</el-button>
</div>
</template>
<script>
import Vue from 'vue'
import ColorPicker from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
export default {}
</script>
<style lang="scss">
</style>
最佳答案
这个“快速入门”片段from the element github page会让你走向正确的方向:
import Vue from 'vue'
import Element from 'element-ui'
Vue.use(Element)
// or
import {
Select,
Button
// ...
} from 'element-ui'
Vue.component(Select.name, Select)
Vue.component(Button.name, Button)
基本上,您要么使用 Vue.use
语法加载所有元素(我相信这会将所有元素加载到您的包中,所以您可能不想这样做,如果您'您的应用中没有使用大量元素组件),或者您在组件中加载元素的 Button
组件:
<template>
<div id="app">
<el-button type="primary" round>Primary</el-button>
</div>
</template>
<script>
import Vue from 'vue'
import ColorPicker from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// mind this new line:
import {Button} from 'element-ui'
export default {}
</script>
<style lang="scss">
</style>
关于javascript - 找不到Vuejs框架的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51809196/