- Vue.js Quick Start Guide
- Ajdin Imsirovic
- 163字
- 2021-06-24 18:23:54
Using Vue's data option as a function
Note that the data option of our Vue instance can be either an object or a function. An example of data as an object can be seen in the previous code. Using data as a function is easy as well.
Data as an object doesn't work well with reusable components. For this reason, using data as a function is, generally speaking, a more useful way to use the data option in Vue.
Let's see another pen. This time, we'll use the data option as a function, instead of as an object. The pen is available here: https://codepen.io/AjdinImsirovic/pen/aKVJgd. The only change we'll make is in our Vue code:
new Vue({
el: '#entryPoint',
data() {
return {
heading1: 'Just an h1 heading here',
heading2: 'heading 2 here',
paragraph1: 'Vue JS data as a function'
}
}
})
Now that we're familiar with the very basics of Vue syntax, let's look at what it can be used for.
推薦閱讀
- 網(wǎng)絡(luò)協(xié)議工程
- Aptana Studio Beginner's Guide
- 面向物聯(lián)網(wǎng)的CC2530與傳感器應(yīng)用開發(fā)
- SOA用戶指南
- SEO 20日
- 工業(yè)控制網(wǎng)絡(luò)安全技術(shù)與實(shí)踐
- 社交電商運(yùn)營策略、技巧與實(shí)操
- HCNA網(wǎng)絡(luò)技術(shù)
- 正在爆發(fā)的互聯(lián)網(wǎng)革命
- 2018網(wǎng)信發(fā)展報(bào)告
- 物聯(lián)網(wǎng)與無線傳感器網(wǎng)絡(luò)
- NB-IoT物聯(lián)網(wǎng)技術(shù)解析與案例詳解
- 城域網(wǎng)與廣域網(wǎng)(第2版)
- 網(wǎng)絡(luò)AI+:2030后的未來網(wǎng)絡(luò)
- 一本書讀懂TCP/IP