VueJs条件车把 [英] VueJs Conditional handlebars

查看:55
本文介绍了VueJs条件车把的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据其文档,但eslint回来并出现错误:

I'm trying to use VueJs conditional rendering using handlebars in vueJs 2.0 as per their documentation but eslint is coming back with and error:

- avoid using JavaScript keyword as property name: "if" in expression {{#if ok}}
- avoid using JavaScript keyword as property name: "if" in expression {{/if}}

$中使用JavaScript关键字作为属性名称: if b
$ b

VueJs似乎没有渲染它。

VueJs does not seem to be rendering it.

<!-- Handlebars template -->
{{#if ok}}
  <h1>Yes</h1>
{{/if}}


推荐答案

如果如果您尝试使用Vue.js语法,则文档仅概述了Vue.js所做的工作。您将使用 v-if 指令。

If you are trying to use Vue.js syntax, the documentation outlines just a few lines down what's done for Vue.js. You would use the v-if directive.

<h1 v-if="ok">Yes</h1>

如果像您提到的那样,您想与Vue.js一起使用Handlebars,请注意它们在模板中使用相同的 {{大括号。您可能需要像这样更改Vue对花括号的使用...

If like you mentioned, you're wanting to use Handlebars alongside Vue.js, note that both of them use the same {{ curly braces in templates. You may need to change Vue's use of the curly braces like so...

Vue.config.delimiters = ['<%', '%>'];

这篇关于VueJs条件车把的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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