Vue2.0 模块组件的引入

qq_39704122 qq_39704122 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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没有规范化吗



...全文
评论 4
收藏 已收藏
分享
返回顶部
qq_39704122
JavaScript 87,983 成员 224,680 内容