Created
September 25, 2018 19:37
-
-
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.
This file contains 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
<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