javascript - Pass Attribute as a Component Parameter in Vue.js -
i'm creating test component in vue.js. want pass parameter use in template follows:
vue.component('test', { props: ['href'], template: '<li><a href="{{href}}"><slot></slot></a></li>' });
in html file:
<test href="/">tvest</test>
but property href
not binding attribute.
<li><a href="{{href}}">tvest</a></li>
how can in vue.js?
you need get rid of brackets around href
, specify binding data property using v-bind
directive:
<li><a v-bind:href="href"><slot></slot></a></li>
Comments
Post a Comment