0👍
you could use it with a computed property:
new Vue({
el: "#app",
data: {
ip: "10.1.1.1"
},
computed: {
ipUrl: function() {
return `http://example.com/${this.ip}`;
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17-beta.0/vue.js"></script>
<div id="app">
<a :href="ipUrl">{{ip}}</a>
</div>
- [Vuejs]-How to run js code before everything in the page? I have session check in js and it should redirect to another page
- [Vuejs]-How to create filters for a Vue component
0👍
You need to write a JS Expression inside :href
, like
<a :href="'http://example.com/' + ip">IP</a>
Note the single quotes (devoting string) inside the double quotes (enclosing attribute value/definition).
- [Vuejs]-Vue nested routes issue with rendering child component
- [Vuejs]-Vue instance data not the same as network response, where is the bug?
Source:stackexchange.com