Skip to content

Instantly share code, notes, and snippets.

@rigor789
Created September 25, 2018 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rigor789/39f7c83263633deee3168b0801df25ca to your computer and use it in GitHub Desktop.
Save rigor789/39f7c83263633deee3168b0801df25ca to your computer and use it in GitHub Desktop.
A snippet for NativeScript-Vue to track the current path on the frame.
<Frame @loaded="onFrameLoaded" />
<!-- and in all the <Page> elements -->
<Page path="/path-of-this-page">...</Page>
<script>
export default {
data() {
return {
currentPath: ''
}
},
methods: {
onFrameLoaded({object}) {
const self = this;
let _currentEntry = object._currentEntry;
Object.defineProperty(object, '_currentEntry', {
get() {
return _currentEntry
},
set(value) {
_currentEntry = value
if (value.resolvedPage) {
self.currentPath = value.resolvedPage.path || ''
}
}
})
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment