当前位置: 首页 > news >正文

手机上如何做网站网页制作工具的是

手机上如何做网站,网页制作工具的是,关键词优化排名软件流量词,兰州做网站多少钱Vue.js使用-ajax使用 1.为什么要使用ajax 前面的例子#xff0c;使用的是本地模拟数据#xff0c;通过ajax请求服务器数据。 2.使用jquery的ajax库示例 new Vue({el: #app,data: {searchQuery: ,columns: [{name: name, iskey: true}, {name: age},{name: sex, dataSource:…Vue.js使用-ajax使用 1.为什么要使用ajax 前面的例子使用的是本地模拟数据通过ajax请求服务器数据。 2.使用jquery的ajax库示例 new Vue({el: #app,data: {searchQuery: ,columns: [{name: name, iskey: true}, {name: age},{name: sex, dataSource:[Male, Female]}],peoples: []},ready: function () {this.getPeoples();},methods: {getPeoples: function () {var vm this;$.ajax({url: http://localhost:20000/my_test,type: get,dataType: json,success: function (data) {vm.$set(peoples, data.result);},error: function(xhr, errorType, error) {alert(Ajax request error, errorType: errorType , error: error)}});}} })3.vue-resource库 vue是基于数据驱动的不需要直接操作DOM因此没有必要引入jquery vue提供了一款轻量的http请求库vue-resource vue-resource除了提供http请求外还提供了inteceptor拦截器功能在访问前访问后做处理。 4.vue-resource语法-使用$http对象 // 基于全局Vue对象使用http Vue.http.get(/someUrl,[options]).then(successCallback, errorCallback); Vue.http.post(/someUrl,[body],[options]).then(successCallback, errorCallback); // 在一个Vue实例内使用$http this.$http.get(/someUrl,[options]).then(sucessCallback, errorCallback); this.$http.post(/someUrl,[body],[options]).then(successCallback, errorCallback);then方法的回调函数写法有两种第一种是传统的函数写法第二种是更简洁的Lambda表达式写法。 //传统写法 this.$http.get(/someUrl,[options]).then(function(response){//响应成功回调 },function(response){//响应错误回调 });//Lambda写法 this.$http.get(someUrl,[options]).then((response){//响应成功回调 },(response){//响应错误回调 });5.vue-resource示例 script srcjs/vue-resource.js/script script new Vue({el: #app,data: {searchQuery: ,columns: [{name: name, iskey: true}, {name: age},{name: sex, dataSource:[Male, Female]}],peoples: []},ready: function () {this.getPeoples();},methods: {getPeoples: function () {var vm this;vm.$http.get(http://localhost:20000/my_test).then(function (data) {var newdata JSON.parse(data.body)vm.$set(peoples, newdata.result)}).catch(function (response) {console.log(response)})}}}) /script6.vue-resource用法-使用resource对象除了使用resource对象 除了使用resource对象除了使用http对象访问http还可以使用$resource对象来访问。 resource服务默认提供以下几种action: get:{method: ‘GET’}, save:{method: ‘POST’}, query:{method: ‘GET’}, update:{method: ‘PUT’}, remove:{method: ‘DELETE’}, delete:{method: ‘DELETE’}, resource对象使用示例如下 new Vue({el: #app,data: {searchQuery: ,columns: [{name: name, iskey: true}, {name: age},{name: sex, dataSource:[Male, Female]}],peoples: []},ready: function () {this.getPeoples();},methods: {getPeoples: function () {var vm this;var resource this.$resource(http://localhost:20000/my_test)resource.get().then(function (data) {var newdata JSON.parse(data.body)vm.$set(peoples, newdata.result)}).catch(function (response) {console.log(response)})}}})7.拦截器interceptor 语法如下 Vue.http.interceptors.push(function(request, next){//...//请求发送前的处理逻辑//...next(function(response){//...//请求发送后的处理逻辑//...//根据请求的状态response参数会返回给successCallback或errorCallbackreturn response})})8.拦截器interceptor使用示例 div idhelploading v-showshowLoading/loading/div template idloading-templatediv classloading-overlaydiv classsk-three-bouncediv classsk-child sk-bounce1/divdiv classsk-child sk-bounce2/divdiv classsk-child sk-bounce3/div/div/div/template script var help new Vue({el: #help,data: {showLoading: false},components: {loading: {template: #loading-template}}})Vue.http.interceptors.push(function(request, next){help.showLoading truenext(function (response) {help.showLoading falsereturn response})}) /script9.vue-resource的优点 vue-resource比jquery轻量可以使用Vue.http或者Vue.resource处理HTTP请求两者没有什么区别。 另外可以是用interceptor在请求前和请求后附加一些行为。
http://www.huolong8.cn/news/345321/

相关文章:

  • 专业的网站建设案例公司装修合同
  • 网站扫描怎么做门户网站与搜索引擎的区别
  • 做美陈3d模型网站模仿别人网站侵权
  • 北京康迪建设监理咨询有限公司网站6做熟食的网站美食网站
  • wordpress建娱乐站长沙seo推广
  • 文案交流网站建筑建设行业网站
  • 高中生做网站网页如何做网页设计
  • 2015网站建设广东省网站免备案表
  • muse cc 做网站怎么再贴吧给自己的网站做宣传
  • 网站建设与维护工作申请号的网站
  • 贵阳微网站建设公司哪家好百度推广怎么弄
  • 做摄影和后期的兼职网站猎头公司是啥意思
  • 郑州网站制作专业乐云seo著名营销成功案例
  • 菏泽网站建设效果wordpress怎么创建目录页面
  • 用虚拟机做网站服务器大众点评怎么做团购网站
  • 网站的劣势做优惠券网站赚钱吗
  • 农场会员营销网站建设wordpress 等级
  • 文明网站建设培训体会网站嵌入js
  • 好的网站建设商家wordpress theme 插件
  • 太原营销型网站建设河北建设工程招标协会网站
  • 网乐科技网站建设成都网络营销搜索推广优势
  • 青浦建设机械网站游戏网站开发毕业设计
  • 苏州华亭建设工程有限公司网站wordpress简约企业商城
  • 网站文章怎么做分享qq建站工具有什么用
  • 建设银行网站改手机号易居房产cms
  • 网站建设需要怎样的经营范围国内用react做的网站
  • 外贸网站推广计划江苏省宿迁市建设局网站首页
  • 如何网站开发语言公众号接入小程序
  • 烟台H5网站设计公司网站域名备案系统
  • 浙江省兰溪建设局网站做网站汉中