Closed PikachuHy closed 6 years ago
demo main.js (expose function homepath)
'use strict'; const carlo = require('carlo'); const os = require('os'); const path = require('path'); (async () => { const app = await carlo.launch( { width: 1000, height: 500, userDataDir: path.join(os.homedir(), '.carlosysinfo'), args: process.env.DEV === 'true' ? ['--auto-open-devtools-for-tabs'] : [] }); app.on('exit', () => process.exit()); app.serveFolder(__dirname + '/dist'); await app.exposeFunction('homepath', homepath); await app.load('index.html'); })(); function homepath() { return os.homedir() }
main.vue (Vue Single File Components)
<template> <div id="app"> {{ path }} </div> </template> <script> export default { name: 'app', components: {}, data() { return { path: '' } }, async mounted () { // ???? How to this.path = homepath() } } </script>
it not work
Uncaught (in promise) ReferenceError: homepath is not defined
use window.homepath()
window.homepath()
nice, I'm messing around with something similar but with react. window. was what I used as djyde mentioned
https://github.com/nickbouldien/carlos
it work. thanks
demo main.js (expose function homepath)
main.vue (Vue Single File Components)
it not work