flexbox-item 如果距离不设置很大,会挤在一起?
注意下面代码的
this指向,这样就会老报错cant set Prototype *problem*,究其原因就是因为this指向不对,修改的话将其改为箭头函数
mounted () {
console.log(11111)
axios.get('http://localhost:8080/api/test')
.then( function(response) {
//console.log(this.problem)
console.log(response.data);
this.problem=response.data
})
.catch(function (error) {
console.log(error);
});
},
接着上面的问题,如果像下面这样写,会报一个warn,注意我们设置了this.problemList=response.data

如图注意response

warn
接着打印下 response,注意response.data是什么?

response
注意response.data这并不是我们要的对象response.data.data才是。
想想之所以会报那个warn是因为我们遍历的时候没读到problem?!!why 我也不知道
后面避免这个错误的话就数据直接用最里层的,res.data.data.problem
axios官方文档上写的res.data就是服务器返回的数据啊?为什么我这里是res.dada.data才能得到数据???
如果页面包含子路由,是不是每个页面都要
import VueRouter from vue-router动态引入
注意冒号转化为html用
v-html路由传参数看这里
main.js
{
name:'hotel',
path:'/hotel/:id',
component:Hotel
}
list.vue
<router-link :to="{name:'hotel',params:{id:item.id}}">
hotel.vue
mounted(){
// console.log($route.params.id)
console.log(this.$route.params.id)
// Cannot read property '$route' of undefined
//我想在这里得到参数
},
- vue中路由相关 如果是要带参数过去 那么应该这样写 注意
:
<router-link :to="{name:'hotel',params:{id:item.id}}">// router-link
{
name:'hotel',
path:'/hotel/:id',
component:Hotel
},
```