Safari显示组件错误,而其他浏览器则没有

问题描述 投票:0回答:1

我有一些非常简单的vue代码,如下所示:

Vue.component('tabs', {
    template: `
        <div class="">
            <div class="tabs">
              <ul>
                <li><a>Music</a></li>
                <li><a>Videos</a></li>
                <li><a>Documents</a></li>
              </ul>
            </div>

            <div class="tab-detail">
                <slot></slot>
            </div>
        </div>
    `
});

new Vue ({
    el: '#root'
});

HTML代码

<div id="root" class="container">

    <tabs>

    </tabs>

</div>

我遇到的问题是safari会发出警告:

[Vue warn]: Unknown custom element: <tabs> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

(found in <Root>)

我是Vue初学者,所以我一直在寻找解决方案,但我得到的答案是我应该在组件之后声明new Vue。我做了但我仍然得到这个错误。

safari vue.js
1个回答
2
投票

这是因为Safari不支持es6模板字符串语法``。为了解决这个问题,您应该使用Webpack或Babel来添加对新es6功能的支持。

© www.soinside.com 2019 - 2024. All rights reserved.