简体   繁体   English

如何使用Vue.JS添加属性

[英]How to add a property with Vue.JS

I want to add this property to my button element: 我想将此属性添加到我的按钮元素中:

uk-toggle="target: #id"

So, the result must be: 因此,结果必须是:

<button uk-toggle="target: #id" type="button">Click</button>

But I need to do that with Vue.JS and I don't know how, I'm trying with this: 但是我需要使用Vue.JS来做到这一点,但我不知道如何,我正在尝试这样做:

<button v-bind: uk-toggle= "target: 'movie.title'" type="button">

But it doesn't works, so.. any ideas? 但这不起作用,所以..有什么想法吗? thanks 谢谢

I'm assuming that you have movie.title defined on your component data and you want that value to end up as value for uk-toggle . 我假设您在组件数据上定义了movie.title ,并且希望该值最终作为uk-toggle值。

In that case try this: 在这种情况下,请尝试以下操作:

<button :uk-toggle= "'target:' + movie.title" type="button">

uk toggle work like this 英国这样的切换工作

     <button class="uk-button uk-button-default" type="button" 
       uk-toggle="target: #toggle-usage">Toggle</button>
        <p id="toggle-usage">Hello</p>

https://getuikit.com/docs/toggle https://getuikit.com/docs/toggle

So here in vueJs are you binding the message in movie.title ? 所以在vueJs中,您是否要将消息绑定到movie.title中?

<button :uk-toggle= "target:#toggle-usage" type="button">
<p id="toggle-usage">Hello</p>

try this value is getting bind so you can easily convert to dynamic values 尝试将此值绑定,以便您可以轻松转换为动态值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM