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

kui-loader

v1.0.6

Published

Replace html tag for vue components

Downloads

37

Readme

kui-loader

用途

替换 kui 组件库标签,如定义一个组件 名为 switch, 那么在引用过程种会和 html 本身的标签冲突,所以要进行替换。

安装

npm i kui-loader --save-dev
#or
yarn add kui-loader

用法

example : index.vue

<template>
  <div>
    <Switch true-text="Yes" false-text="No" />
    <br />
    <Switch true-text="1" false-text="0" />
    <br />
    <Switch true-text="On" false-text="Off" />
    <br />
    <Image 
      width="120" 
      src="https://www.chuchur.com/upload/avatar/test_300.jpg"
    />
    <br />
    <Switch>
      <Icon type="checkmark" slot="checked"/>
      <Icon type="close" slot="unchecked"/>
    </Switch>
    <Switch>
      <Icon type="logo-apple" slot="checked"/>
      <Icon type="logo-windows" slot="unchecked"/>
    </Switch>
    <br />
     <Switch>
      <Icon type="airplane" slot="unchecked"/>
      <Icon type="wifi" slot="checked"/>
    </Switch>
  </div>
</template>
<script>
export default{
  data(){
    return{
      checked:false
    }
  }
}
</script>

以上编译不会通过的,所以要进行解析替换标签:

webpack.conf.js

module.exports = {
  bail: true,
  module: {
    rules: [
      {
        test: /\.vue$/,
        use: [
          { loader: 'vue-loader' },
          { loader: 'kui-loader', options: { prefix: false } } //放在最后保证优先加载
        ]
      }
    ]
  }
}

在非 template/render 模式下,你也可以这么用 ,使用 k-前缀来区分 ,部分组件也可以使用 - 来分割,看示例:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>KUI - example</title>
    <link rel="stylesheet" type="text/css" href="http://unpkg.com/kui-vue/dist/k-ui.css">
    <script src="//unpkg.com/kui-icons/lib/kui-icons.js"></script>
    <script src="//unpkg.com/moment/min/moment.min.js"></script>
    <script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script>
    <script type="text/javascript" src="http://unpkg.com/kui-vue/dist/k-ui.js"></script>
</head>

<body>
  <div id="app">
    <k-button @click="show">Click me!</k-button>
    <k-modal v-model="visible" title="Welcome">Welcome to use KUI</k-modal>

    <k-image 
        width="120" 
        src="https://www.chuchur.com/upload/avatar/test_300.jpg"
      />
    <br />

    <k-button-group size="small" circle>
      <button ><k-icon type="chevron-back"/> Backward</button>
      <button>Forward <k-icon type="chevron-forward"/></button>
    </k-button-group>
  </div>
</body>
<script>
new Vue({
  el: '#app',
  data: {
    visible: false
  },
  methods: {
    show: function () {
      this.visible = true;
    }
  }
})
</script>
</html>

记得开启替换选项:

-      { loader: 'kui-loader', options: { prefix: false } }
+      { loader: 'kui-loader', options: { prefix: true } }