man.js引入

import Vue from 'vue'
import VueResource from 'vue-resource'
import App from './App.vue' Vue.use(VueResource)//内部会给vm对象和组件添加一个属性$http
/* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>'
})
<template>
<div>
<div v-if="!repoUrl">loding</div>
<div v-else>most star repo is<a :href="repoUrl">{{repoName}}</a></div>
</div>
</template> <script>
export default{
data(){
return{
repoUrl:'',
repoName:''
}
},
mounted(){
// 发送ajax请求
const url='https://api.github.com/search/repositories?q=v&sort=stars'
this.$http.get(url).then(
response=>{ const result=response.data
const mostRepo=result.items[]
this.repoUrl=mostRepo.html_url
this.repoName=mostRepo.name
},
respone=>{
alert('请求失败')
}
)
}
}
</script> <style> </style>

vue-resource请求的更多相关文章

  1. vue resource 携带cookie请求 vue cookie 跨域

    vue resource 携带cookie请求 vue cookie 跨域 1.依赖VueResource 确保已安装vue-resource到项目中,找到当前项目,命令行输入: npm instal ...

  2. VUE开发请求本地数据的配置,旧版本dev-server.js,新版本webpack.dev.conf.js

    VUE开发请求本地数据的配置,早期的vue-lic下面有dev-server.js和dev-client.js两文件,请求本地数据在dev-server.js里配置,最新的vue-webpack-te ...

  3. Vue 网络请求

    Vue网络请求,用的是vue-resource 1. 首先需要安装vue-resource npm install vue-resource 2. 安装好之后,会在package.json文件中自动加 ...

  4. 手把手教你vue配置请求本地json数据

    本篇文章主要介绍了vue配置请求本地json数据的方法,分享给大家,具体如下:在build文件夹下找到webpack.dev.conf.js文件,在const portfinder = require ...

  5. vue开发请求本地模拟数据的配置方法(转)

    VUE开发请求本地数据的配置,早期的vue-lic下面有dev-server.js和dev-client.js两文件,请求本地数据在dev-server.js里配置,最新的vue-webpack-te ...

  6. Vue之resource请求数据

    导入resource文件 <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js& ...

  7. vue resource 携带cookie请求 vue cookie 跨域(六)

    1.依赖VueResource  确保已安装vue-resource到项目中,找到当前项目,命令行输入: npm install vue-resource --save 在主方法添加 过滤 Vue.h ...

  8. vue 数据请求

    作者QQ:1095737364    QQ群:123300273     欢迎加入!   要引入模块: vue-resource 1.在package.json中的dependencies中添加vue ...

  9. vue.js 请求数据

    VUE.JS var vm = new Vue({ el:"#list", data:{ gridData: "", }, mounted: function( ...

  10. vue数据请求

    我是vue菜鸟,第一次用vue做项目,写一些自己的理解,可能有些不正确,欢迎纠正. vue开发环境要配置本地代理服务.把config文件加下的index.js里的dev添加一些内容, dev: { e ...

随机推荐

  1. 【归纳】springboot中的IOC注解:注册bean和使用bean

    目前了解的springboot中IOC注解主要分为两类: 1. 注册bean:@Component和@Repository.@Service.@Controller .@Configuration 共 ...

  2. 过滤器为JSP文件生成静态页面

    用过滤器为JSP文件生成静态页面,这只是一个简单的实例,客户端浏览器第一次请求JSP页面时,服务器将生成对应的HTML文件,以后访问同一JSP文件,将转为访问生成的HTML文件.一.过滤器 packa ...

  3. json书写格式

    1.数组方式 [ ] [{ "id" : 1 , "name" : "xiaoming" },{ "id" : 2 , ...

  4. 【记录】Java NIO实现网络模块遇到的BUG

    1.背景 通过JavaNio实现一个简单的网络模块,有点像Netty的线程模型,一个线程(AcceptThread)建立新连接,把新连接绑定到某个SelectorThread,SelectorThre ...

  5. 给元素绑定 class

    <div id="app04"> <label v-bind:class="{'Class1':Class1}">sasjadjagd& ...

  6. python--前端之CSS

    CSS产生背景: 为了让网页元素的样式更加丰富,也为了让网页的内容和样式能拆分开,CSS由此思想而诞生,CSS是 Cascading Style Sheets 的首字母缩写,意思是层叠样式表. 有了C ...

  7. dedecms SESSION变量覆盖导致SQL注入漏洞修补方案

    dedecms的/plus/advancedsearch.php中,直接从$_SESSION[$sqlhash]获取值作为$query带入SQL查询,这个漏洞的利用前提是session.auto_st ...

  8. zabbix监控winserver网卡流量

    当前基于windows2008系统安装配置zabbix客户端,服务端为linux系统 1.设置防火墙规则 开启防火墙入站(tcp和udp)10050端口 2.在zabbix官网上下载windows包 ...

  9. 開啟windows 7 ,10 的熱點功能(無線熱點)

    開啟windows 7 ,10 的熱點功能: 1.首先要確定你的電腦無線芯片有無熱點功能  # netsh wlan show drivers    Hosted network supported ...

  10. python find()函数

    实例(Python 2.0+)  str1 = "this is string example....wow!!!"; str2 = "exam"; print ...