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

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.

主站蜘蛛池模板: 成安县| 海伦市| 三穗县| 那坡县| 金门县| 永泰县| 余江县| 尼勒克县| 惠来县| 安图县| 盐边县| 横山县| 田东县| 宁陕县| 崇阳县| 江川县| 衡东县| 于田县| 固始县| 吐鲁番市| 泸水县| 乌拉特前旗| 三穗县| 海盐县| 富宁县| 利津县| 张家港市| 马龙县| 桦南县| 内黄县| 岳池县| 南宁市| 浦县| 财经| 瑞昌市| 武穴市| 丽江市| 泽库县| 平果县| 龙门县| 南阳市|