vue+webpack项目实战开发vue之路前端之美-VueJs

vue+webpack app项目(6)

2016-09-18  本文已影响784人  Obeing

step6 利用vue-resource 获取数据

Paste_Image.png
  import VueResource from 'vue-resource'
Paste_Image.png

If your web server can't handle requests encoded as application/json , you can enable the emulateJSON option. This will send the request as application/x-www-form-urlencoded MIME type, as if from an normal HTML form.
--- 如果Web服务器无法处理编码为application/json的请求,你可以启用emulateJSON选项。启用该选项后,请求会以application/x-www-form-urlencoded作为MIME type,就像普通的HTML表单一样。

Paste_Image.png Paste_Image.png Paste_Image.png

点击进入详情页面

  <div class="card" v-on:click="goDetail">
        <slot></slot>   
    </div>
       methods:{
             goDetail (){
                this.$dispatch('GoDetailRouter', $(this.$el).index())
              }
        }
Paste_Image.png
events :{//监听子组件
      GoDetailRouter (msg){
           router.go({
            name: 'detail', 
            params: {
              Lcontent:encodeURIComponent(this.$data.task1[msg].Lcontent)

            }
          });
      }
  }
router.js
 '/home/detail/:Lcontent': {
            name:'detail',
            component (resolve) {
            require(['./views/detail'], resolve)
          }
        }
route: {
          data: function (transition) {

           this.$set('Lcontent',decodeURIComponent(this.$route.params.Lcontent)); 
          }
        }

切换钩子子函数

Paste_Image.png
上一篇 下一篇

猜你喜欢

热点阅读