美文网首页
ie 兼容 .vue 文件

ie 兼容 .vue 文件

作者: jeneen1129 | 来源:发表于2021-06-15 16:41 被阅读0次

    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 浏览器报错

    最终,把 data() {} 改成了 data: function(){} 解决

    可见 ie11 不支持 () 直接定义函数, 需要使用 function 关键字才可以成功定义函数

    以上个人经验,请勿转载!

    相关文章

      网友评论

          本文标题:ie 兼容 .vue 文件

          本文链接:https://www.haomeiwen.com/subject/hyizeltx.html