vue.js简介
vue是法语中视图的意思,Vue.js是一个轻巧、高性能、可组件化的MVVM库,同时拥有非常容易上手的API。
一、动态参数显示
ajax异步请求后,接收到返回的data参数并显示在前端
1.1 引入js,也加入了jQuery
<script></script><script></script>
1.2 html
<div>
<p>{{ message }}</p>
<button>显示数据</button>
</div>
1.3 JS
注意:这里JS一定要放在$(function() {})里面,或者是写到body里面
new Vue({
el: '#app',
data: {
message: ''
},
methods: {
showData: function () {
var _self = this;
$.ajax({
type: 'GET',
url: '...',
success:function(data) {
_self.message = JSON.stringify(data);
}
});
}
}
})
二、动态列表显示
开始展示一个空白列表,ajax异步请求后,接收到返回的data列表信息并显示
2.1 引入js,也加入了jquery
<script></script><script></script>
2.2 html
<div>
<table>
<thead><tr>
<th>ID</th>
<th>名称</th>
<th>条形码</th>
<th>简称</th>
</tr></thead>
<tbody><tr>
<td>{{goods.id}}</td>
<td>{{goods.name}}</td>
<td>{{goods.barcode}}</td>
<td>{{goods.shortName}}</td>
</tr></tbody>
</table>
<button>查询</button><br><br>
</div>
2.3 JS
var goodsVue = new Vue({
el: '#app',
data: {
goodsList : ''
},
methods: {
nameSearch: function () {
var _self = this;
$.ajax({
type: 'GET',
url: '...',
success:function(data) {
_self.goodsList = data;
}
});
}
}
})
前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!










