step1: 首先,请满足 html 引入vue 兼容ie
step2: .vue 文件需要 html 引入 http-vue-loader
http-vue-loader: npm 库
<script src="https://unpkg.com/http-vue-loader"></script>
<script>
// 使用httpVueLoader
Vue.use(httpVueLoader);
new Vue({
el: '#app',
data: function () {
return {
}
},
components: {
// 将组建加入组建库
'component': httpVueLoader('component.vue')
}
})
</script>
component.vue 如下:
<template>
<div class="hello">Hello {{who}} ! {{total}}</div>
</template>
<script>
module.exports = {
data() {
return {
who: 'world'
}
},
props: {
total: String,
}
}
</script>
<style>
.hello {
background-color: #ffe;
}
</style>
step3: ie11 浏览器报错
![](https://img.haomeiwen.com/i17273442/683366815e3a3be0.png)
最终,把 data() {}
改成了 data: function(){}
解决
可见 ie11 不支持 () 直接定义函数, 需要使用 function 关键字才可以成功定义函数
以上个人经验,请勿转载!
网友评论