Skip to content

[vue] 你有二次封装过ElementUI组件吗? #401

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

Open
haizhilin2013 opened this issue Jun 20, 2019 · 7 comments
Open

[vue] 你有二次封装过ElementUI组件吗? #401

haizhilin2013 opened this issue Jun 20, 2019 · 7 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

[vue] 你有二次封装过ElementUI组件吗?

@haizhilin2013 haizhilin2013 added the vue vue label Jun 20, 2019
@wenyejie
Copy link

有啊! 类似于分页, 表格, 毕竟每个项目的这些东西, 比如pageSize, size, 这些在每个项目基本都是统一的,
设置起来会有四五个参数prop是固定的, 我不可能每次使用的时候都设置一次

@forever-z-133
Copy link

popover + button 的组件,点击该按钮后还有个二次确认或选择的交互。
InfiniteScroll 封装个简单的带触底加载的列表。

@zhuss
Copy link

zhuss commented Jul 10, 2019

价格输入框
功能: v-mode="1000" 单位分;输入框显示 10.00;手动输入100显示100.00;
image

@liuxsen
Copy link

liuxsen commented Jul 25, 2019

价格输入框
功能: v-mode="1000" 单位分;输入框显示 10.00;手动输入100显示100.00;
image

你怎么封装的?

@zhuss
Copy link

zhuss commented Jul 29, 2019

价格输入框
功能: v-mode="1000" 单位分;输入框显示 10.00;手动输入100显示100.00;
image

你怎么封装的?

其实是简单的做了下处理,大概如下

<template>
  <el-input
    placeholder="价格"
    v-model="current"
    :disabled="disabled"
    :maxlength="8"
    @change="change"
  ></el-input>
</template>
<script>
export default {
  props: {
    value: Number,
    disabled: Boolean
  },
  data() {
    return {
      current: ""
    };
  },
  watch: {
    value(val) {
      if (val > 0) {
        this.current = (val / 100).toFixed(2);
      } else {
        this.current = "";
      }
    }
  },
  created() {
    if (this.value > 0) {
      this.current = (this.value / 100).toFixed(2);
    } else {
      this.current = "";
    }
  },
  methods: {
    change() {
      let value = this.current * 100 || 0;
      this.current = (value / 100).toFixed(2);
      this.$emit("input", value.toFixed(0) * 1);
    }
  }
};
</script>

@liuxsen
Copy link

liuxsen commented Jul 29, 2019 via email

@azui999
Copy link

azui999 commented Aug 3, 2021

封装分页,上传文件

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

No branches or pull requests

6 participants