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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -