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

宝鸡手机版网站建设企业营销模式

宝鸡手机版网站建设,企业营销模式,wordpress上弹广告,网站建设策划书提纲Vue基础18github案例静态页面第三方样式引入(以bootstrap举例)App.vueSearch.vueList.vue列表展示接口地址使用全局事件总线进行兄弟间组件通信Search.vueList.vue完善案例List.vueSearch.vue补充知识点:{...this.info,...this.dataObj}效果呈…

Vue基础18

  • github案例
    • 静态页面
      • 第三方样式引入(以bootstrap举例)
      • App.vue
      • Search.vue
      • List.vue
    • 列表展示
      • 接口地址
      • 使用全局事件总线进行兄弟间组件通信
        • Search.vue
        • List.vue
    • 完善案例
      • List.vue
      • Search.vue
      • 补充知识点:{...this.info,...this.dataObj}
      • 效果呈现
  • vue-resource
    • 安装
    • 引用
      • main.js
    • 使用
      • Search.vue

github案例

静态页面

第三方样式引入(以bootstrap举例)

  1. public中创建文件夹css,将样式放入
    在这里插入图片描述

  2. 在index.html中使用link引入

<!--   引入第三方样式   --><link rel="stylesheet" href="<%= BASE_URL %>css/bootstrap.css">

在这里插入图片描述

App.vue

<template><div class="bg"><Search/><List/></div>
</template><script>
import Search from "@/components/Search";
import List from "@/components/List";
export default {name: "App",components: {Search, List},methods:{}
}
</script><style lang="less"></style>

Search.vue

<template><div class="jumbotron bg"><h1>Search Github Users</h1><p><input type="text" placeholder="输入你想要搜索的用户名"><a class="btn btn-default btn-lg" href="#" role="button">Search</a></p></div>
</template><script>export default {name: "Search"}
</script><style scoped lang="less">
.bg{height: 250px;margin: 0 20px;padding-left: 50px;padding-top: 50px;.title{font-size: 20px;}input{margin-right: 10px;}
}
</style>

List.vue

<template>
<div class="bg"><div class="predict" v-show="isShow">welcome to use</div><div class="pro-list"><div class="pro-item" v-for="item in content"><img src="@/assets/logo.png" alt=""><div class="text">122555</div></div></div>
</div>
</template><script>export default {name: "List",data(){return{isShow:false,content:["","","","","","","","","",""]}}}
</script><style scoped lang="less">
.bg{margin: 0 20px;font-size: 24px;.pro-list{display: flex;flex-wrap: wrap;.pro-item{margin: 50px  120px;.text{text-align: center;}}}}
</style>

列表展示

接口地址

https://api.github.com/search/users?q=xxx

用到的响应值:

  1. avatar_url:头像链接
  2. html_url:用户详情页
  3. login:用户名

使用全局事件总线进行兄弟间组件通信

Search.vue

<template><div class="jumbotron bg"><h1>Search Github Users</h1><p><input type="text" placeholder="输入你想要搜索的用户名" v-model="keywords"><a class="btn btn-default btn-lg" href="#" role="button" @click="searchUsers">Search</a></p></div>
</template><script>
import axios from "axios";export default {name: "Search",data(){return{keywords:"",}},methods:{searchUsers(){if(this.keywords.trim()=="") return alert("用户输入的内容不得为空")axios.get(`https://api.github.com/search/users?q=`+this.keywords).then(response=>{// console.log(response.data.items)console.log("请求成功了~")this.$bus.$emit('getUsersList',response.data.items)},error=>{console.log(error.msg)})}}}
</script><style scoped lang="less">
.bg{height: 250px;margin: 0 20px;padding-left: 50px;padding-top: 50px;.title{font-size: 20px;}input{margin-right: 10px;}
}
</style>

List.vue

<template>
<div class="bg"><div class="predict" v-show="!users.length">welcome to use</div><div class="pro-list"><div class="pro-item" v-for="user in users" :key="user.login"><a :href="user.html_url" class="aitem"><img :src="user.avatar_url" alt=""></a><div class="text">{{ user.login }}</div></div></div>
</div>
</template><script>export default {name: "List",data(){return{isShow:false,users:[],}},mounted() {this.$bus.$on('getUsersList',(users)=>{this.users=users})}}
</script><style scoped lang="less">
.bg{margin: 0 20px;font-size: 24px;.pro-list{display: flex;flex-wrap: wrap;.pro-item{margin: 50px  120px;.aitem{display: inline-block;width: 200px;height: 200px;}img{width: 200px;height: 200px;}.text{text-align: center;}}}}
</style>

请添加图片描述

完善案例

在这里插入图片描述

List.vue

<template>
<div class="bg"><h1 class="predict" v-show="info.isFirst">欢迎使用!</h1><h1 v-show="info.isLoading">加载中...</h1><h1 v-show="info.emsg">错误信息:{{info.emsg}}</h1><div class="pro-list"><div class="pro-item" v-for="user in info.users" :key="user.login"><a :href="user.html_url" class="aitem"><img :src="user.avatar_url" alt=""></a><div class="text">{{ user.login }}</div></div></div>
</div>
</template><script>export default {name: "List",data(){return{isShow:false,users:[],info:{isFirst:true,isLoading:false,emsg:"",users:[]}}},mounted() {this.$bus.$on('updateListData',(dataObj)=>{this.info={...this.info,...dataObj}})}}
</script><style scoped lang="less">
.bg{margin: 0 20px;font-size: 24px;.pro-list{display: flex;flex-wrap: wrap;.pro-item{margin: 50px  120px;.aitem{display: inline-block;width: 200px;height: 200px;}img{width: 200px;height: 200px;}.text{text-align: center;}}}}
</style>

Search.vue

<template><div class="jumbotron bg"><h1>Search Github Users</h1><p><input type="text" placeholder="输入你想要搜索的用户名" v-model="keywords"><a class="btn btn-default btn-lg" href="#" role="button" @click="searchUsers">Search</a></p></div>
</template><script>
import axios from "axios";export default {name: "Search",data(){return{keywords:"",}},methods:{searchUsers(){if(this.keywords.trim()=="") return alert("用户输入的内容不得为空")else{this.$bus.$emit("updateListData",{isFirst:false,isLoading:true,emsg:"",users:[]})axios.get(`https://api.github.com/search/users?q=${this.keywords}`).then(response=>{// console.log(response.data.items)console.log("请求成功了~")this.$bus.$emit('updateListData',{isLoading:false,emsg:"",users:response.data.items})},error=>{console.log(error.msg)this.$bus.$emit("updateListData",{isLoading:false,emsg:error.message,users:[]})})}}}}
</script><style scoped lang="less">
.bg{height: 250px;margin: 0 20px;padding-left: 50px;padding-top: 50px;.title{font-size: 20px;}input{margin-right: 10px;}
}
</style>

补充知识点:{…this.info,…this.dataObj}

{…this.info,…this.dataObj}:通过字面量的形式合并一下对象
以this.dataObj为主,依次替换this.info中的属性的值,但是this.dataObj中没有的数据,还是沿用this.info中的

效果呈现

请添加图片描述

vue-resource

发送Ajax的5种方式:
1.xhr
2.jQuery
3.axios
4.fetch
5.vue-resource(插件库)对xhr的封装

安装

npm i vue-resource
在这里插入图片描述

引用

main.js

import Vue from 'vue'import App from './App'
//引入vue-resource插件
import vueresource from 'vue-resource'Vue.config.productionTip = false
//使用vue-resource插件
Vue.use(vueresource)new Vue({el: "#app",render: h => h(App),beforeCreate() {Vue.prototype.$bus = this}
})

使用

与axios一致,只需要将axios替换成this.$http就行

this.$http.get(`https://api.github.com/search/users?q=${this.keywords}`).then(response=>{// console.log(response.data.items)console.log("请求成功了~")this.$bus.$emit('updateListData',{isLoading:false,emsg:"",users:response.data.items})},error=>{console.log(error.msg)this.$bus.$emit("updateListData",{isLoading:false,emsg:error.message,users:[]})})

Search.vue

<template><div class="jumbotron bg"><h1>Search Github Users</h1><p><input type="text" placeholder="输入你想要搜索的用户名" v-model="keywords"><a class="btn btn-default btn-lg" href="#" role="button" @click="searchUsers">Search</a></p></div>
</template><script>
import axios from "axios";export default {name: "Search",data(){return{keywords:"",}},methods:{searchUsers(){if(this.keywords&&this.keywords.trim()=="") return alert("用户输入的内容不得为空")else{this.$bus.$emit("updateListData",{isFirst:false,isLoading:true,emsg:"",users:[]})this.$http.get(`https://api.github.com/search/users?q=${this.keywords}`).then(response=>{// console.log(response.data.items)console.log("请求成功了~")this.$bus.$emit('updateListData',{isLoading:false,emsg:"",users:response.data.items})},error=>{console.log(error.msg)this.$bus.$emit("updateListData",{isLoading:false,emsg:error.message,users:[]})})}}}}
</script><style scoped lang="less">
.bg{height: 250px;margin: 0 20px;padding-left: 50px;padding-top: 50px;.title{font-size: 20px;}input{margin-right: 10px;}
}
</style>

在这里插入图片描述

http://www.khdw.cn/news/59872.html

相关文章:

  • 济南网站建设(力选聚搜网络)徐州网络推广服务
  • 做网站设计的公司叫什么搜索引擎下载安装
  • ps怎样做网站大图怎么找需要做推广的公司
  • 游戏攻略网站怎么做推广策略
  • 网站后台帐号密码破解怎么接推广
  • 自定义网站图标如何提高网站在百度的排名
  • 网站挂马处理百度快照南昌seo排名公司
  • 网站哪个公司做的重庆企业站seo
  • 三网合一网站建设合同网站建设产品介绍
  • 做电脑网站用什么软件chrome谷歌浏览器
  • 皇马logo做网站公众号推广费用一般多少
  • 黄金网站app免费视频下载全国病毒感染最新消息
  • 黑别人网站互联网营销培训课程
  • 广州领域设计网络运营有限公司seo排名优化培训怎样
  • 网站正在建设中 源码下载免费搜索引擎入口
  • 顺德技术支持 骏域网站建设专家灰色词秒收录代发
  • 惠州seo网站排名网络软营销
  • 上海网站建设做物流一seo短视频网页入口引流网站
  • 新乡市做网站找哪个公司seo知识总结
  • sm做任务的网站有哪些推广app赚钱项目
  • 哈尔滨微网站建设系统清理优化工具
  • 做区位分析的地图网站百度关键词点击器
  • 政府网站建设的国际网站策划书案例
  • 专做婚宴用酒是网站搜索引擎排名中国
  • 做外包网站的公司是怎样的seo社区
  • 济南著名网站建设昆明seo博客
  • 网站建设需要桂ajax吗营销模式100个经典案例
  • 深圳市移动端网站建设襄阳seo培训
  • 建设 互动 网站 模式win7优化极致性能
  • 做网站的要求seo教学视频教程