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

vtw

v0.1.8-beta1

Published

一个将vue单文件组件转成小程序组件的工具

Downloads

7

Readme

一个将vue单文件组件转成小程序组件的工具

使用

查看帮助

vtw

基本用法

vtw <input> [output] -c <path>

配置项

  • importAppend: string[] 增加的依赖
  • importRemove: string[] 删除的依赖
  • importReplace: object 替换依赖源

例子:

{
  "importAppend": [
    "import add from 'add';"
  ],
  "importRemove": [
    "vue"
  ],
  "importReplace": {
    "old-dep": "new-dep"
  }
}

使用示例

  • /path/from 目录下的vue文件,转换并写入到 /path/to 目录下
vtw /path/from /path/to
  • /path 目录下的Test.vue文件,转换并写入到 /path/to 目录下
vtw /path/Test.vue /path/to
  • /path 目录下的Test.vue文件,转换输出到控制台
vtw /path/Test.vue
  • 自定义配置
vtw /path/Test.vue -c ./config.json

特性

template 转 wxml

支持:

  • 标签转换
div -> view
img -> image
  • 部分内置指令,v-text, v-show, v-if, v-else-if, v-else, v-for
  • 属性 v-bind:prop | :prop
  • 事件 v-on:event | @event

script 转 js

支持:

  • 生命周期
  • data
  • props
  • computed
  • watch
  • components,只会转换相对路径的依赖
  • setData,所有对 this 视图变量的引用都会加入data成员,对它的更新都会转成setData调用

css | scss | less

目前只是简单拷贝而已

⚠️ 注意事项

  • 事件和属性不支持动态绑定
<!-- 通过 $props 将父组件的 props 一起传给子组件 -->
<child-component v-bind="$props"></child-component>

<!-- 对象语法 (2.4.0+) -->
<button v-on="{ mousedown: doThis, mouseup: doThat }"></button>
  • 不支持修饰符。指令修饰符,事件修饰符和属性修饰符
  • 不支持指令,以下内置指令也不支持
`v-html`, `v-once`, `v-pre`, `v-cloak`, `v-once`
  • vue 内置的组件,exp: component, transiton
  • 不支持默认插槽,不支持作用域插槽slot-scope
<button type="submit">
  <slot>Submit</slot>
</button>
  • 组件不支持 filters, directives, mixins 配置
  • vue 里提供的组件实例属性和方法都不支持
`$data, $props, $el, $options, $parent, $root, $children, $slots, $scopedSlots, $refs, $isServer, $attrs, $listeners, $watch, $on`