2👍
Use computed
.
Insert below code under data
.
computed: {
FullName() {
return this.FirstName + this.LastName;
},
}
You can use this.FullName
inside the component.
- [Vuejs]-How can I convert this type of date (22-07-2020 12:00) to ISO date
- [Vuejs]-Locale keeps resetting between switching pages. Nuxt-i18n
1👍
Welcome to SO!
To get derived data, Vue has feature called computed
properties
data: () => ({
FirstName: Mark,
LastName: Zuckerberg,
}),
computed: () => {
FullName() {
return this.FirstName + this.LastName
}
}
Moreover computed properties are cached, so it will only be recomputed when the associated data are changes.
Hope this helps.
- [Vuejs]-Vue for input.length change background color
- [Vuejs]-Why Eslint add a space automatically for object property name with hyphen?
0👍
You could achieve this using computed properties.
Something like:
new Vue({
el: "#addr",
template: `<div class = templateField>
<h1>Hello {{ firstName }}!</h1>
<p>Hello {{ lastName }}!</p>
<p>{{fullName}}</p>
</div>`,
data: {
firstName: "Mark",
lastName: "Zuckerberg"
},
computed: {
fullName: function () {
return this.firstName + " " + this.lastName;
}
}
});
Here is a working example.
- [Vuejs]-VueJS axios allow to click button only once, second time allow after data received
- [Vuejs]-Firebase Role Managment
Source:stackexchange.com