framework7-vue ^2.x pushState

2018-05-31  本文已影响0人  forever_youyou

以前碰过一点 framework7,昨天试了一下framework7-vue ^2.3.0,在需要将 pushState 设置为 true 时发现之前的用法无效:

// 1.0 之前
new Vue({
    el: '#app',
    template: '<app/>',
    // Init Framework7 by passing parameters here
    framework7: {
        root: '#app',
        /* Uncomment to enable Material theme: */
        // material: true,
        routes: Routes,
        pushState: true,
        pushStateSeparator: '#',
        ...
    },

随后找了下 官网文档 有说明,

// Note that all following parameters can be used in global app parameters under view property to set defaults for all views. For example:
var app = new Framework7({
  view: {
    iosDynamicNavbar: false,
    xhrCache: false,
  }
});
TIM截图20180531094847.png

就是view的属性需要设置在 framework7 对象的view属性上,如下:

new Vue({
  el: '#app',
  template: '<App/>',
  framework7: {
    id: 'com.it1025.m',
    name: 'framework7-vue-demo',
    theme: 'ios', // auto, ios, material
    view: {  // 注意这里 pushState 是 view 的属性,直接是直接挂在 framework7 上
      pushState: true,
      pushStateSeparator: '#',
    },
    routes: Routes
  },
  // router,
  components: {App}
});

之后 pushState 就有效了:


TIM截图20180531095505.png
上一篇 下一篇

猜你喜欢

热点阅读