0.6.11 • Published 3 years ago

@onemin-table/elem-input v0.6.11

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

🚀 schema-based输入框模板组件, 集成el-popover组件,实现关注点集中的反馈模式.

安装

$ npm i @onemin-table/elem-input
# OR
$ yarn add @onemin-table/elem-input

用法

在 HTML 中以 UMD 的形式使用:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.0/theme-chalk/index.min.css" rel="stylesheet">
</head>
<body>
  <main id="app">
    <elem-input
      v-model="foo"
      :border-color="foo === 'a' ? 'red' : ''"
      :width="foo === 'a' ? 200 : 300"
      append=".com"
    />
  </main>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.min.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.0/index.min.js"></script>
  <script src="./node_modules/@onemin-table/elem-input/dist/elem-input.min.js"></script>
  <script>
    new Vue({
      el: '#app',
      components: {
        ElemInput,
      },
      data() {
        return {
          foo: '',
        };
      },
    });
  </script>
</body>
</html>

在工程项目中以 CommonJS / ESM 的形式使用:

<template>
  <div>
    <button @click="active = !active">切换</button>
    <span>{{ !active ? '' : '激活' }}</span>
    <elem-input
      v-model="foo"
      :popoverVisible="active"
      :border-color="active ? 'red' : ''"
      :prefix-slot-render="prefixSlotRender"
      width="300"
      append=".com"
      prepend="https://"
      popover-content="content"
      @input="handleChange"
    />
  </div>
</template>

<script>
  export default {
    data() {
      return {
        foo: '1',

        active: true,
      };
    },

    methods: {
      handleChange(val) {
        console.warn(this.foo, val);
      },

      prefixSlotRender(h) {
        return <i class="el-icon-time el-input__icon" />;
      },
    },
  };
</script>

代码预览

代码预览

属性

参数说明类型
prefix-slot-render选择器头部内容渲染函数, 相当于el-input的prefix slotFunction
suffix-slot-render选择器尾部内容渲染函数, 相当于el-input的suffix slotFunction
append-slot-render选择器后置内容渲染函数, 相当于el-input的append slotFunction
prepend-slot-render选择器前置内容渲染函数, 相当于el-input的prepend slotFunction
append选择器后置内容字符串, 优先级低于appendSlotRenderString
prepend选择器前置内容字符串, 优先级低于prependSlotRenderString
data-prop元素标识,会被绑定到DOM元素的data-prop属性上, 默认为空String
border-color选择器边框颜色, 可用于校验不通过的提示,设为空字符串可还原String
background-color选择器背景颜色, 可用于校验不通过的提示,设为空字符串可还原String
color选择器字体颜色, 可用于校验不通过的提示,设为空字符串可还原String
popover-visible<el-popover>弹出框是否显示Boolean
popover-content<el-popover>弹出框内容String
popover-attrs<el-popover>的属性Object
popover-listeners<el-popover>的事件Object
popover-slot-render弹出框渲染函数, 相当于el-popover的default slotFunction

其他继承自el-input的属性见element-ui文档

事件

继承自el-input的事件见element-ui文档

方法

继承自el-input的方法见element-ui文档

0.6.11

3 years ago

0.6.10

3 years ago

0.6.7

3 years ago

0.6.6

3 years ago

0.6.9

3 years ago

0.6.8

3 years ago

0.6.3

3 years ago

0.6.5

3 years ago

0.6.4

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.3.0

3 years ago

0.4.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago