Building your mobile app with Vue + Framework7

Installation

Install Vue

1
$ npm install vue-cli -g

Start a project

1
2
3
4
$ vue init webpack demo
$ cd demo
$ npm install
$ npm run server

Install Framework7

1
$ npm install framework7 framework7-vue --save

Project Structure

  • src/assets - folder with static assets (images)
  • src/components - folder with custom .vue components
  • src/css - put custom app CSS styles here. Don’t forget to import them in main.js
  • src/pages - app .vue pages
  • src/main.js - main app file where you include/import all required libs and init app
  • src/routes.js - app routes
  • src/app.vue - main app structure/component

Initialize App

main.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Vue from 'vue'
import Framework7 from 'framework7'
import Framework7Vue from 'framework7-vue'
import Framework7Theme from 'framework7/dist/css/framework7.ios.min.css'
import Framework7ThemeColors from 'framework7/dist/css/framework7.ios.colors.min.css'
import App from './App'
import Routes from './routes.js'
Vue.config.productionTip = false
Vue.use(Framework7Vue)
new Vue({
el: '#app',
template: '<App/>',
framework7: {
root: '#app',
routes: Routes
},
components: { App }
})

App.vue

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<template>
<!-- App -->
<div id="app">
<!-- Status bar overlay for full screen mode (Cordova or PhoneGap) -->
<f7-statusbar></f7-statusbar>
<!-- Views -->
<f7-views>
<!-- Your main view, should have "main" prop -->
<f7-view main>
<!-- Pages container, because we use fixed navbar and toolbar, it has additional appropriate props -->
<f7-pages navbar-fixed toolbar-fixed>
<!-- Initial Page -->
<f7-page>
<!-- Top Navbar-->
<f7-navbar title="Awesome App"></f7-navbar>
<!-- Toolbar-->
<f7-toolbar>
<f7-link>Link 1</f7-link>
<f7-link>Link 2</f7-link>
</f7-toolbar>
<!-- Page Content -->
<p>Page content goes here</p>
<f7-link href="/about/">About App</f7-link>
</f7-page>
</f7-pages>
</f7-view>
</f7-views>
</div>
</template>
<script>
export default {}
</script>