官术网_书友最值得收藏!

Mock listing

While we're developing, it'd be nice to work with some mock data so that we can see how our completed page will look. I've included sample/data.js in the project for this very reason. Let's load it in our document, making sure it goes above ourapp.jsfile.

index.html:

<body>
<p id="toolbar">...</p>
<p id="app">...</p>
<script src="node_modules/vue/dist/vue.js"></script>
<script src="sample/data.js"></script>
<script src="app.js"></script>
</body>

Have a look at the file and you'll see that it declares a sample object. We will now utilize it in our data configuration.

app.js:

data: {
  title: sample.title,
  address: sample.address,
  about: sample.about
}

Once you save and refresh, you'll see more realistic data on the page:

Figure 2.5. Page including mock-listing sample

Using global variables split over different script files in this way is not an ideal practice. We'll only be doing this in the prototype, though, and later we'll get this mock-listing sample from the server.

主站蜘蛛池模板: 贵港市| 那坡县| 涿州市| 灵石县| 嵊州市| 修文县| 双辽市| 保靖县| 略阳县| 安图县| 四子王旗| 娄底市| 曲麻莱县| 葫芦岛市| 汝城县| 清镇市| 罗平县| 永昌县| 香河县| 黄陵县| 长白| 黄大仙区| 海兴县| 韩城市| 县级市| 蒙自县| 兰考县| 巴彦县| 乌苏市| 湟中县| 望城县| 漳平市| 泾阳县| 依安县| 定南县| 宁安市| 金坛市| 隆子县| 团风县| 集贤县| 韶山市|