How to install vue-resource
Oct 27, 2021 pm 05:36 PMInstallation method: 1. Open the cmd command window and execute the "cd project directory" and "npm i vue vue-resource --save-dev" commands; 2. Configure the entry file "main.js" and use The import command can import vue-resource.
The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.
vue-resource is a plug-in used in vue to request network data. This plug-in depends on vue. Simply put, it is used to adjust the interface.
Installation
cd 项目目录 npm i vue vue-resource --save-dev
Configure in the entry file main.js
import VueResource from 'vue-resource'Vue.use(VueResource)
That’s it Used directly:
get request:
this.$http.get('地址',{params: {参数}}).then(function(res) { console.log(res) // 响应成功回调 },function(res) { console.log(res) // 响应错误回调 })
post request:
this.$http.post('地址',{参数},{emulateJSON:true}).then( function(res) { console.log(res.data) })
jsonp request:
this.$http.jsonp("地址",{params:{参数}}).then( function(res){ console.log(res.data.s) })
Related recommendations: " vue.js tutorial》
The above is the detailed content of How to install vue-resource. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The difference between event and $event in vue

The difference between export and export default in vue

What scenarios can event modifiers in vue be used for?
