This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In v4 we had | |
app.request.promise(...) | |
.then((data) => { | |
console.log(`Response data is: ${data}`) | |
}) | |
.catch((status) => { | |
console.log(status); | |
}) | |
// In v5 it is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = new Framework7(/*...*/); | |
if (app.online) { | |
console.log('online!'); | |
} | |
if (!app.online) { | |
console.log('offline!'); | |
} | |
app.on('online', () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<div class="panel panel-left panel-reveal"> | |
... | |
</div> | |
<div class="panel panel-right panel-cover"> | |
... | |
</div> | |
</div> | |
<script> | |
var app = new Framework7({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<!-- | |
* new "panel-init" class to auto init the panel | |
* swipe and visibleBreakpoint passed as data- attributes | |
--> | |
<div class="panel panel-left panel-reveal panel-init" data-swipe="true" data-visible-breakpoint="768"> | |
... | |
</div> | |
<div class="panel panel-right panel-cover panel-init" data-visible-breakpoint="1024"> | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// return promise | |
{ | |
//... | |
data() { | |
return new Promise((resolve) => { | |
fetch('some/path') | |
.then(res => res.json()) | |
.then(user => resolve({ user })) | |
}); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.$setState({foo: 'bar'}); | |
this.$setState({john: 'doe'}); | |
this.$tick(() => { | |
// DOM updated | |
}); | |
// Or with callback | |
this.$setState({foo: 'bar'}, () => { | |
// DOM updated | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myMixin = { | |
data: function() { | |
return { | |
foo: 'bar', | |
} | |
}, | |
mounted: function() { | |
console.log('mounted') | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from 'famework7'; | |
export default class extends Component { | |
data() { | |
return { foo: 'bar' } | |
} | |
mounted() { | |
console.log('mounted'); | |
this.onMounted(); // call method | |
} |