0.2.10 • Published 2 years ago

simple-component-vue3 v0.2.10

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

simple-component-vue3

This template should help get you started developing with Vue 3 in Vite.

Recommended IDE Setup

VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).

Type Support for .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension 1) Run Extensions: Show Built-in Extensions from VSCode's command palette 2) Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.

Customize configuration

See Vite Configuration Reference.

Project Setup

npm install

To install web component into your project you need to initialize it inside

index.html (vanilla js or vue)

<script type="module">
    import {register} from "path_to/simple-component-vue3/dist/index.js"
    register()
</script>

index.js (react root script)

    import {register} from "path_to/simple-component-vue3/dist/index.js"
    register()

vue can also initialize it inside

main.js/ts script

    import {register} from "path_to/simple-component-vue3/dist/index.js"
    register()

USAGE

First component is direct which gets msg as property in vue.

<simple-component-vue3-direct msg="something"></simple-component-vue3-direct>

Second component is non-direct which gets msg as property in vue.

<simple-component-vue3-ref msg="something"></simple-component-vue3-ref>

Third component is emit does not work right now

<simple-component-vue3-emit></simple-component-vue3-emit>

Fourth component is vmodel which creates input field that shows input below it.

<simple-component-vue3-vmodel></simple-component-vue3-vmodel>

Fifth component is broadcast which uses broadcast channel. Declaration of BroadcastChannel in your project should be like this with 'test-channel' name required

// Declaration
const bc = new BroadcastChannel('test-channel')

// Usage
bc.onmessage = (event) => {
        console.log(event.data);
    }

// even.data gets object of data sent from vue component (parameters: type, title)

To use component declare it like this.

<simple-component-vue3-broadcast></simple-component-vue3-broadcast>

Component creates input field which value is broadcasted via BroadcastChannel .data object is holding input value in parameter "title"

Compile and Hot-Reload for Development

npm run dev

Type-Check, Compile and Minify for Production

npm run build
0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.5

2 years ago

0.1.5

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago