How to use page init?


#1

hello,code like this,dont work,why?


#2

Место где app.on - если у вас Cordova, то события с большой вероятностью вы не поймаете, т.е. init будет после device ready.


#3

hi,can you reply english?


#4

try assign url prop to .main-view
<div class="view view-main" url="/"></div>
and also make sure u install routes as well


#5

thanks, but the same


#6

you have to declare routes at init app
> var app = new Framework7({

  // App root element
  root: '#app',
  // App Name
  name: 'My App',
  // App id
  id: 'com.myapp.test',
  // Enable swipe panel
  panel: {
    swipe: 'left',
  },
  // you have to declare routes at init app
> routes: [
    {
      path: '/about/',
      url: 'about.html',
    },
  ],
  // ... other parameters
});

#7

Here on forum, there are lot of similar topics. It happens because you add your page:init handlers AFTER home page was initialized. Add them before new Framework7 or add it to app parameters events, on: {pageInit() {....}}


#8

thanks very much! it is work


#9

Не “url”, а data-url.

И так нельзя писать. Или добавить view-init или убрать data-url="/", а добавить url при создании view с помощью JS.
Здесь https://framework7.io/docs/view.html#view-auto-initialization " In this case we may pass them in data- attributes.