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

中小企业门户网站建设策略北京市建设中心网站

中小企业门户网站建设策略,北京市建设中心网站,wordpress登陆后台,图书网站建设论文文章目录axios实现vue-resource实现上一篇#xff1a;#xff08;三十六#xff09;Vue解决Ajax跨域问题 先看一个github搜索案例 有一个搜索框#xff0c;输入相关用户名#xff0c;就能模糊搜索出用户#xff0c;展现到下方 第一步#xff1a;我们用到了第三方样式库… 文章目录axios实现vue-resource实现上一篇三十六Vue解决Ajax跨域问题 先看一个github搜索案例 有一个搜索框输入相关用户名就能模糊搜索出用户展现到下方 第一步我们用到了第三方样式库bootstrap首先需要在public文件夹见一个css文件夹放入样式库然后在index.html页面进行引入 !-- 引入第三方样式 --link relstylesheet href%BASE_URL%css/bootstrap.css第二步拆分组件搜索跟文本框为一个组件Search展示用户为一个组件List axios实现 通用的 Ajax 请求库, 官方推荐使用比较广泛 axios安装命令npm i axios App组件 templatediv classcontainerSearch/List//div /template script import Search from /components/Search; import List from /components/List; export default {name: App,components: {List, Search}, } /script style /styleSeach组件 templatesection classjumbotronh3 classjumbotron-headingSearch Github Users/h3divinput typetext placeholderenter the name you search v-modelkeyWord/nbsp;button clicksearchUsersSearch/button/div/section /templatescriptimport axios from axios;export default {// eslint-disable-next-line vue/multi-word-component-namesname: Search,data(){return{keyWord:}},methods:{searchUsers(){if (this.keyWord ){alert(输入不能为空)return}//请求前更新List的数据this.$bus.$emit(updateListData,{isFirst:false,isLoading:true,errMsg:,users:[]})axios.get(https://api.github.com/search/users?q${this.keyWord}).then(response {//请求成功后更新List的数据this.$bus.$emit(updateListData,{isLoading:false,errMsg:,users:response.data.items})},error {console.log(请求失败,error.message)//请求后更新List的数据this.$bus.$emit(updateListData,{isLoading:false,errMsg:error.message,users:[]})})}} } /script style scoped /styleList组件 templatediv classrow!--展示用户列表--div v-showinfo.users.length classcard v-foruser in info.users :keyuser.logina :hrefuser.html_url target_blankimg :srcuser.avatar_url stylewidth: 100px//ap classcard-text{{user.login}}/p/div!--展示欢迎词--h2 v-showinfo.isFirst欢迎使用/h2!--展示加载中--h2 v-showinfo.isLoading加载中..../h2!--展示错误信息--h2 v-showinfo.errMsg{{info.errMsg}}/h2/div /templatescript export default {// eslint-disable-next-line vue/multi-word-component-namesname: List,data(){return{info: {isFirst:true,isLoading:false,errMsg:,users:[]}}},mounted() {this.$bus.$on(updateListData,(dataObj){this.info {...this.info,...dataObj}})} } /scriptstyle scoped .album {min-height: 50rem; /* Can be removed; just added for demo purposes */padding-top: 3rem;padding-bottom: 3rem;background-color: #f7f7f7; }.card {float: left;width: 33.333%;padding: .75rem;margin-bottom: 2rem;border: 1px solid #efefef;text-align: center; }.card img {margin-bottom: .75rem;border-radius: 100px; }.card-text {font-size: 85%; } /stylevue-resource实现 vue-resource是一个插件库对ajax进行了封装用法与axios差不多。 vue-resource安装命令npm i vue-resource 使用这个插件之后Vue和VueComponent身上就多了个$http通过$http.get或$http.post进行Ajax请求 vue 插件库, vue1.x 使用广泛官方已不维护。 安装完之后需要在mian.js进行引入 import vueResource from vue-resource; Vue.use(vueResource)Seach组件改为 templatesection classjumbotronh3 classjumbotron-headingSearch Github Users/h3divinput typetext placeholderenter the name you search v-modelkeyWord/nbsp;button clicksearchUsersSearch/button/div/section /templatescriptimport axios from axios;export default {// eslint-disable-next-line vue/multi-word-component-namesname: Search,data(){return{keyWord:}},methods:{searchUsers(){if (this.keyWord ){alert(输入不能为空)return}//请求前更新List的数据this.$bus.$emit(updateListData,{isFirst:false,isLoading:true,errMsg:,users:[]})this.$http.get(https://api.github.com/search/users?q${this.keyWord}).then(response {//请求成功后更新List的数据this.$bus.$emit(updateListData,{isLoading:false,errMsg:,users:response.data.items})},error {console.log(请求失败,error.message)//请求后更新List的数据this.$bus.$emit(updateListData,{isLoading:false,errMsg:error.message,users:[]})})}} } /scriptstyle scoped/style
http://www.hkea.cn/news/14412549/

相关文章:

  • 屋领网站固链徐州网站app开发
  • 国外手表网站房地产 网站 欣赏
  • 海口网站制作策划提供网站建设出售
  • 纪检监察网站建设的意义能自己做生物实验的网站
  • 苏州网站建设及推广门户地方网站 策略
  • 昆明网站建设天锐科技广西壮族自治区工商行政管理局
  • 公司网站建设设计方案wordpress中文 速度慢
  • 专业制作企业网站wordpress动静分离oss代码
  • 做吃穿住行网站全球军情动态
  • 公司网站搭建费用网站 前台 后台
  • 电子商务行业网站有哪些涟水住房和城乡建设局网站
  • 网站开发 零基础广电基础设施建设官方网站
  • 农产品如何建设网站郑州市哪里有网站建设
  • 婚庆网站源码seo外链网
  • 如何利用国外网站开发客户服务器 多个网站
  • 恶意镜像网站程序生物科技网站建设 中企动力北京
  • 做网站复杂吗wordpress 可视化 编辑
  • 简阳电力建设立项网站无锡大型设计网站报价
  • 网站没有百度权重网站负责人幕布照片
  • 盐山做网站广德县建设协会网站
  • 广州市财贸建设开发监理网站深圳市住房和建设局网官网
  • 北京建设监理网站网页设计和网站建设实战大全
  • c 网站开发案例源码网站推广有什么方法有哪些
  • 丹东新区建设发展集团网站游戏网站建设视频教程
  • 杭州做网点卖服装在那个网站网络营销人员招聘
  • 网站建设综合软件属于网站开发吗
  • 做一家网站的成本做外贸需要关注的网站有什么问题
  • 北京品牌建设网站公司排名下载中国移动app免费下载安装
  • 广州市建设集团网站首页wap网站部署
  • 网站建设可以在家做吗好的高端企业网站建设公司