Use configuration in Vue.js (with the use of the SSH framework) {The rest of the code is ibid}

Source: Internet
Author: User

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding= "UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>insert title here</title>
<body>

Refresh:
<br/>

<div id= "MyView2" >
<span> Please enter the title:</span>
<input v-model= "BookName"/>

</div>

<br/>
<table border= "1px" id= "MyView" >
<tr>
<th>ID</th>
<th> title </th>
<th> Price </th>
</tr>
<tr v-for= "book in Booklist" >
<td>{{book.id}}</td>
<td>{{book.name}}</td>
<td>{{book.price}}</td>
</tr>
</table>
</body>
<script src= "${pagecontext.request.contextpath}/js/vue.js" ></script>
<script src= "${pagecontext.request.contextpath}/js/jquery-3.2.1.min.js" ></script>
<script type= "Text/javascript" >
Booklist cannot be empty, otherwise it will fail with view binding
var clientinput = {bookname: '};//This JSON purpose is used for submission to server queries
var myViewModel2 = new Vue ({
El: ' #myView2 ',
Data:clientinput,
methods:{
Querybook:function () {
Enter the contents of the client $ (' #bookName '). Val ()
Assign a value to clientinput this JSON
Clientinput.bookname = $ (' #bookName '). Val ();
$.ajax ({
URL: ' 44.jsp ',
URL: ' Bookaction_querybook ',
Type: ' GET ',
Data:clientinput,
DataType: ' JSON ',
timeout:2000,
Success:function (Result) {
alert (result.booklist);
Mymodel.booklist = result.booklist;
},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
Alert (' Server busy, please do not speak dirty words, theoretically everyone is civilized people ');
alert (textstatus+xmlhttprequest.status);
}
});
}

}
});


var MyModel = {booklist:[]};
var Myviewmodel = new Vue ({
El: ' #myView ',
Data:mymodel
});
For the purpose of the function, in order to "reuse"
function GetData () {
Alert (11);
$.ajax ({
URL: "Bookaction_getallbook",//Backend API address
Type: ' GET ',//http:post/get
Data:postdata,//refers to parameters submitted to the backend by the client
DataType: ' json ',//server return type Text,json
timeout:2000,
Success:function (Result) {
Mymodel.booklist = result.booklist;
},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
Alert (' Server busy, please do not speak dirty words, theoretically everyone is civilized people ');
alert (textstatus+xmlhttprequest.status);
}
});
}
GetData ();


</script>

Use configuration in Vue.js (with the use of the SSH framework) {The rest of the code is ibid}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.