Vue2.0 模块组件的引入
index.js:
import NoDataS from './index.vue'
const noDataLists = {
install: function(Vue) {
// 注册并获取组件,然后在main.js中引用,在Vue.use()就可以了
Vue.component('noDataLists', NoDataS)
}
}
export default noDataLists
index.vue:
<template>
<!-- NoDataWords 可以灵活控制每个页面显示的内容 -->
<!-- NoDataHeight 可以灵活控制每个页面的高度 -->
<!-- 如果你的页面都是统一的字体,统一的样式,那就直接在这写死就好了 -->
<div class="NoDataAtAll W100"
:style="{height: NoDataHeight }">{{NoDataWords}}</div>
</template>
<script>
export default {
// 就是基本的父子组件传值
props: ["NoDataHeight", "NoDataWords"],
data() {
return {};
},
methods: {}
};
</script>
<style lang="scss" scoped>
.NoDataAtAll {
font-size: 14px;
color: #909399;
}
</style>
main.js:引入
HTML页面:
<script type="module" src="js/main.js"></script>
现在就是一直报错:
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
不知道是index.vue没有规范化吗