npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-propsync

v0.1.3

Published

vue-propsync:vue 组件的混合对象,主要用于组件编写时混入调用。

Downloads

12

Readme

vue-propsync

NPM version GitHub forks GitHub stars NPM download GitHub license

vue-propsync:vue 组件的混合对象,主要用于组件编写时混入调用。

Thanks

Introduction and Use

主要功能

  1. 实现了在组件内自动创建 prop 对应的 data,方便组件内修改 prop 使用。解决了 vue2.0 中不允许组件内直接修改 prop 的设计。
  2. 实现了组件外修改组件 prop 的双向绑定,子组件状态改变时将会通知父组件,同时父组件状态改变时也会通知子组件
  3. 父组件使用 v-model 来帮定数据,子组件通过 value 来保存 v-model 的值
  4. 父组件不需要写方法来同步子组件传来 v-model 的值,子组件也不再需要写过多的监听方法和将数据同步至父组件的方法

食用方法

  1. 编写组件:在选项对象中增加 mixins: [propsync] 即可,如:
<script>
import propsync from 'vue-propsync'
export default {
name: 'hello',
mixins: [propsync]
}
</script>
  1. 调用组件:在调用组件的 templat 处,增加一个 v-model 来绑定数据,如:
<modal v-model="isShow"></modal>
<script>
export default {
name: 'app',
data () {
  return {
    isShow: false
  }
}
}
</script>
  1. 子组件:如:
<template>
<div class="modal" :value="value" v-show="sync_value">
  <!-- 由于 v-model 一定要由 value 来接受传值,以上接受父组件数据为固定写法,复制粘贴即可,本插件将会为 value 创建一个副本 sync_value, 子组件需要绑定该变量 -->
  <div class="close" @click="cancel">测试</div>
</div>
</template>
<script>
import propsync from 'vue-propsync'
export default {
name: 'hello',
mixins: [propsync],
props: {
  value: {
    type: Boolean,
    default: false,
    isSync: true // 需要开启双向绑定的一定要写这句话,默认不会将所有的 prop 开启双向绑定
  }
},
methods: {
  cancel () {
    this.sync_value = false // 注意 props 是不能直接改变的,则需要改变本插件创建的副本即可
  }
}
}
</script>