0.0.7 • Published 6 years ago

abeluiux-nwjs-argv v0.0.7

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

Arguments received by nwjs for vuejs 2.x

Install

$ npm i abeluiux-nwjs-argv
or
$ yarn add abeluiux-nwjs-argv

Usage

  • In the main.js of your project vuejs
import 'abeluiux-nwjs-argv'
// 
import Vue from 'vue'

new Vue({
    el       : {...} ,
    template : {...} ,
})
  • Send arguments to nwjs executable
$ nw -foo --bar=bar --baz="baz tar"
  • Use in any component vuejs
<template>{...}</template>

<script>

    export default {
        created() {
            console.log(nwjs.argv)
            // {foo: true, bar:'bar', baz='baz tar', ...}
        }
    }

</script>
  • Send your arguments as many times as you need
$ nw --new
$ nw --other
<template>{...}</template>

<script>

    export default {
        created() {
            /**
             * nwjs.on.open(function, boolean?)
             * 
             * function : vuejs method
             * boolean  : Return arguments as object or string
             *            Default true
             * 
            */
            nwjs.on.open(this.getArgv)
        },

        methods : {
            getArgv(argv) {
                console.log(argv)
                // {new: true, ...}
                // {other: true, ...}
            }
        }
    }

</script>
  • Send your arguments as object or array
$ nw --person="{'name': 'louis', 'age': '25'}"
$ nw --fruits="['apple', 'orange', {others: ['strawberry']}]"
<template>{...}</template>

<script>

    export default {
        created() {
            nwjs.on.open(this.getArgv)
        },

        methods : {
            getArgv(argv) {
                console.log(argv)
                /**
                    person: {
                        name: 'louis',
                        age: 25
                    }

                    fruits: [
                        'apple',
                        'orange',
                        { others: ['strawberry'] },
                        ...
                    ]
                */
            }
        }
    }

</script>
0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago