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

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.

主站蜘蛛池模板: 札达县| 海盐县| 绥棱县| 新津县| 郧西县| 会昌县| 乌海市| 乌恰县| 玉溪市| 通化市| 南木林县| 长宁县| 衡阳县| 班玛县| 卢氏县| 秀山| 陇西县| 泸定县| 蕲春县| 兴文县| 秦安县| 邹城市| 安福县| 绵竹市| 文成县| 佛冈县| 密云县| 诸暨市| 班玛县| 子长县| 兴文县| 会昌县| 寿阳县| 定安县| 当涂县| 贵阳市| 哈密市| 杭锦旗| 枣强县| 子洲县| 县级市|