【问题标题】:How to put xml template inside vue component property如何将xml模板放入vue组件属性中
【发布时间】:2019-06-06 18:50:16
【问题描述】:

我在 NativeScript 中使用自定义视图插件,并在其文档中:https://market.nativescript.org/plugins/nativescript-filter-select

可以选择使用 xml 添加项目模板。

在我看来,我应该这样传递:

<FilterSelect
    item_template=" xml template here "
/>

我试过了:

<FilterSelect
    item_template="<Label col='0' text='{{ ${this._search_param} }}' 
    textWrap='true' />"

但不起作用。 (不渲染)

谁能帮帮我?

【问题讨论】:

  • 你的意思是它不起作用,插件在此之后根本不起作用或者它没有按预期呈现模板或者你看到任何错误?

标签: vue.js nativescript


【解决方案1】:

为了使这种语法工作,您需要使用 es6 模板文字。所以在你的例子中,这看起来像这样:

<FilterSelect 
   :item_template="`
     <Label col='0' text='{{ ${this._search_param} }}' textWrap='true' />
   `"
/>

这应该允许您使用${} 字符串插值。也不要忘记关闭你的标签。

【讨论】:

  • 成功了!但是我需要在 item_template 处添加一个冒号':'才能走!非常感谢!
  • 哦,是的,您是对的,因为您绑定到自定义属性。我已经更新了。
猜你喜欢
  • 2019-02-23
  • 1970-01-01
  • 2020-05-10
  • 2020-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-18
  • 1970-01-01
相关资源
最近更新 更多