-
Get Started
-
Vue Components
- App
- Accordion
- Action Sheet / Actions
- Badge
- Block / Content Block
- Button
- Cards
- Checkbox
- Chips / Tags
- Contacts List
- Floating Action Button / FAB
- Gauge
- Grid / Layout Grid
- Icon
- Inputs / Form Inputs
- Link
- List View
- List Item
- List Button
- List Index
- Login Screen
- Messagebar
- Messages
- Navbar
- Page
- Panel / Side Panels
- Photo Browser
- Popover
- Popup
- Preloader
- Progressbar
- Radio
- Range Slider
- Searchbar
- Sheet Modal
- Smart Select
- Sortable
- Statusbar
- Stepper
- Subnavbar
- Swiper
- Swipeout
- Tabs
- Toggle
- Toolbar / Tabbar
- View
- Virtual List
Initialize App
After we have our app layout now we need to mount Vue components and initialize the app. You can read about all possible Framework7 initialization parameters in appropriate Framework7 App Parameters section.
Plain Initiliazation Structure
Let's look at the simple plain app structure, where we don't use any bundlers in our app, just a plain html + js files. Full layout again, but with script:
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<!-- ... metas and styles ... -->
<link rel="stylesheet" href="path/to/framework7.min.css">
</head>
<body>
<!-- App Root Element -->
<div id="app">
<!-- Main Framework7 App component where we pass Framework7 params -->
<f7-app :params="$root.f7params">
<f7-statusbar></f7-statusbar>
<f7-view main>
<!-- Initial Page -->
<f7-page>
<f7-navbar title="Awesome App"></f7-navbar>
<f7-toolbar>
<f7-link>Link 1</f7-link>
<f7-link>Link 2</f7-link>
</f7-toolbar>
<p>Page content goes here</p>
<f7-link href="/about/">About App</f7-link>
</f7-page>
</f7-view>
</f7-app>
</div>
<script type="text/javascript" src="path/to/vue.min.js"></script>
<script type="text/javascript" src="path/to/framework7.min.js"></script>
<script type="text/javascript" src="path/to/framework7-vue.min.js"></script>
<script type="text/javascript" src="path/to/my-app.js"></script>
</body>
</html>
/* my-app.js */
// First of all, we need to initialize/enable Framework7 Vue plugin:
// We need to pass Framework7Vue plugin to Framework7's .use() method
Framework7.use(Framework7Vue);
// Init Vue App
new Vue({
// App Root Element
el: '#app',
// App root data
data() {
return {
// Framework7 parameters that we pass to <f7-app> component
f7params: {
// Array with app routes
routes: [...]
// App Name
name: 'My App',
// App id
id: 'com.myapp.test',
// ...
}
};
},
// App root methods
methods: {
// ....
}
})
With Bundlers
If you use Webpack, Rollup or another bundler with ES-next modules support, we may have the following structure:
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<!-- ... metas and styles ... -->
<link rel="stylesheet" href="path/to/framework7.min.css">
</head>
<body>
<!-- App Root Element -->
<div id="app"></div>
<script type="text/javascript" src="path/to/my-app.js"></script>
</body>
</html>
/* my-app.js */
// Import Vue
import Vue from 'vue'
// Import F7 Bundle
import Framework7 from 'framework7/framework7.esm.bundle.js'
// Import F7-Vue Plugin Bundle (with all F7 components registered)
import Framework7Vue from 'framework7-vue/framework7-vue.esm.bundle.js'
// Init F7-Vue Plugin
Framework7.use(Framework7Vue);
// Import Main App component
import App from './app.vue';
// Init App
new Vue({
el: '#app',
render: (h) => h(App),
// ...
});
<!-- app.vue -->
<template>
<!-- Main Framework7 App component where we pass Framework7 params -->
<f7-app :params="f7params">
<f7-statusbar></f7-statusbar>
<!-- initial page is specified in routes.js -->
<f7-view main url="/"></f7-view>
</f7-app>
</template>
<script>
import routes from './routes.js';
export default {
data() {
return {
// Framework7 parameters that we pass to <f7-app> component
f7params: {
// Array with app routes
routes,
// App Name
name: 'My App',
// App id
id: 'com.myapp.test',
// ...
}
}
}
}
</script>
In the examples above:
- we pass Framework7 parameters to the
f7-app
main Framework7 app component in itsparams
property; - element passed in Vue's
el
parameter will be used as Framework7 root element
We also must specify array with routes (if we have navigation between pages in the app). Check out information about Vue Component Extensions, router and routes in the Navigation Router section.