不能使用 Vue.config.delimiters,只能在 new Vue() 上设置分隔符 [英] Can't use Vue.config.delimiters, can only set delimiters on new Vue()

查看:53
本文介绍了不能使用 Vue.config.delimiters,只能在 new Vue() 上设置分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 这个答案,我正在尝试设置 Vue.config.delimiters = ['${', '}'] 以便将 Vue 与服务器端 handlebars 一起使用.

As per this answer, I'm trying to set Vue.config.delimiters = ['${', '}'] in order to use Vue with server-side handlebars.

当我只使用全局配置时,它没有任何作用.

When I just use the global config, it doesn't anything.

当我在新的 Vues 上设置 delimiters 时,它起作用了

When I set delimiters on new Vues, it works

var game = new Vue({
        delimiters: ['${', '}'],
...

我怎样才能让它在一个全局的地方工作,即 Vue.config.delimiter?

How can I make it work in one global place i.e. Vue.config.delimiter?

推荐答案

全局分隔符已在 Vue 2 中删除,因此您现在必须在 Vue 实例上设置它们.来自 Vue Github 页面:

Global delimiters were removed in Vue 2, so you now have to set them on the Vue instance. From the Vue Github page:

...in 2.0 分隔符将成为组件级选项,这意味着您只需为依赖于 DOM 模板的根实例设置它.vueify 或 vue-loader 处理的任何组件都可以继续使用默认分隔符.

...in 2.0 delimiters will become a component-level option, which means you only need to set it for the root instance that relies on in-DOM templates. Any components processed by vueify or vue-loader can just keep using default delimiters.

此更改旨在更轻松地使用 3rd 方组件,因为全局更改分隔符意味着您将无法正确编译它们.

The change is intended to make it easier to use 3rd party components, since changing the delimiters globally means you will not be able to compile them correctly.

这篇关于不能使用 Vue.config.delimiters,只能在 new Vue() 上设置分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆