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

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.

主站蜘蛛池模板: 胶州市| 芒康县| 禄劝| 古丈县| 略阳县| 思茅市| 阳江市| 濮阳县| 通山县| 遂平县| 东至县| 大丰市| 蒲城县| 石城县| 鄯善县| 东山县| 连云港市| 灵丘县| 府谷县| 于都县| 舟曲县| 兴国县| 米脂县| 张家港市| 泾阳县| 孝义市| 昌吉市| 海南省| 包头市| 修武县| 平邑县| 南雄市| 普洱| 沅陵县| 平遥县| 唐河县| 美姑县| 镇江市| 益阳市| 永寿县| 乌恰县|