js下跳转路由
<router-link :to="{path:'/index',query:{name:'lisi',age:23}}"></router-link>
router.push({
path:'/index',
query:{name:'lisi',age:23}
})
vue全家桶
vue-cli:用脚手架搭建项目
vue:mvvm模式开发,数据双向绑定,页面渲染
vue-router:定义路径跳转
vuex:前端数据存储
axios:ajax技术,用来链接后台
element-ui:用来制作html和css,完成响应式和动画
axios技术
axios用来链接后台,执行ajax,封装了promise,处理了兼容性,地域回调,可以执行
多个回调函数。可在node中发送http请求,自动转化json数据,防止XSRF攻击
请求方法
axios.get(路径,参数)
axios.post(路径,参数)
axios.delete(路径,参数)
axios.head(路径,参数)
axios.put(路径,参数)
axios.patch(路径,参数)
axios.options(路径,参数)
axios.request(参数)
使用方式
npm install axios --save 安装axios
npm install axios --S 安装axios
shift+鼠标右键 选择打开命令行窗口,直接打开指定路径位置
get请求方式
axios.get(路径,{参数:值})
.then(function(res){ console.log(res)})
.catch(function(error){ console.log(error)})
request请求方式
axios.request({
url:"/api/News/new_list",
methods: "get",
data:{type:3,page:20},
}).then(function(res){
console.log(res)
}).catch(error=>{console.log(error)})
request的参数
url定义路径
method http请求方式
data 传给后台的变量
headers:{Content-Type:'application/json'} 自定义请求头
params:{type:3,page:20} 发送无格式对象体数据
timeout:1000 指定
VUEjs学习笔记3
最新推荐文章于 2024-05-15 10:07:30 发布