Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add petite-vue plugins support #167

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Add petite-vue plugins support #167

wants to merge 12 commits into from

Conversation

ws-rush
Copy link

@ws-rush ws-rush commented Jul 16, 2022

I am so excited, this is my first pull request on github, I dont know typescript, and I wish this pull request accepted

I did this commit to distribute custom directives as packages then use them with petite-vue, I also added example use in README file, thats it:

Use Plugins

You can write custome directive then distrbute it as a pacage, then add it to create vue, like:

<div v-scope="{counter: 0}" v-log="inside petite-vue scope">
  <button @click="counter++">increase</button>
</div>

<script type="module">
  import log from './log'
  import { createApp } from 'peteite-vue'
  createApp().use(log).mount()
</script>

A plugin code similar to vue plugins code:

// inside log.js plugin file
export default {
  install: (app, options) => {
    app.directive('log', ({exp}) => {
      console.log(exp)
    })
  }
}

wusaby-rush and others added 10 commits August 29, 2022 03:03
Some times like in dialogs we need access to root component from child nodes, also it is a way to access root element from `v-scope` . the next snippet from another PR to expose `$el` to scope, but this PR can solve the same problem also

```html
<textarea
  v-scope="{width: $root.offsetWidth, height: $root.offsetHeight}"
  @click="width = $el.offsetWidth; height = $el.offsetHeight;"
>
{{ width }} &times; {{ height }}
</textarea>
```
@sqllyw
Copy link

sqllyw commented Jul 11, 2023

what is the advantage of use() over directive() ? example:

createApp().directive('log',log).mount() vs 
createApp().use(log).mount()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants