我希望把 id为“vue_id” 做成一个template 并写在 下方的javascript里面,该如何实现?
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<!--如何把 id为“vue_id” 做成一个template 并写在 下方的javascript里面-->
<!-- Template: Start -->
<div class="text-center" id="vue_id">
<div> <a v-for="item in model" v-bind:href="'#'+item.href_value" class="btn btn-primary mrs mbs">{{ item.text_value }}</a></div>
</div>
<!-- Template: End -->
</body>
<script>
var app2 = new Vue({
el: '#vue_id',
// 想要把template写在这里
data: {
test: 'test',
model: []
},
mounted: function() {
axios.get('mark_0220150514.json')
.then(response => {
this.model = response.data;
console.log(response);
})
.catch(error => {
// handle error
console.log(error);
})
}
});
</script>
</html>