Skip to content

ant design vue #310

Description

@uniquejava

全量导入

组件数轻松上20, 我已经没有耐心使用按需导入了。

暴力 import Antd from "ant-design-vue" 提示Antd找不到~, 解决办法: 把babel.config.js中的下面这段删除,

  plugins: [
    [
      "import",
      {
        libraryName: "ant-design-vue",
        libraryDirectory: "es",
        style: true,
      },
    ],
  ],

然后~~

import Vue from "vue";
import Antd from "ant-design-vue";
import "ant-design-vue/dist/antd.less";

Vue.prototype.$message = Antd.message;
Vue.prototype.ok = function(message) {
  this.$message.success(message || "Success.");
};

Vue.use(Antd);

table 中的boolean字段不能显示值

弄个customRender.

<template>
    <a-table
      :columns="mycolumns"
      :dataSource="tasks"
      :pagination="false"
      rowKey="id"
      size="small"
    >
      <span slot="index" slot-scope="text, record, index">{{ index + 1 }}</span>
      <template slot="auto" slot-scope="text">{{ text.toString() }}</template>
</template>
<script>
export default {
data: {
  mycolumns: [
        {
          title: "#",
          dataIndex: "index",
          scopedSlots: { customRender: "index" },
          align: "center",
          width: "5%",
        },
        {
          title: "Auto",
          dataIndex: "auto",
          scopedSlots: { customRender: "auto" },
        },
  ]
}

checkbox 设置初值 要 指定 valuePropName 为 checked

<a-row>
  <a-col :span="12">
    <a-form-item v-bind="formItemLayout" label="Active" :colon="false">
      <a-checkbox
        v-decorator="[
          'active',
          { valuePropName: 'checked', initialValue: formData.active },
        ]"
        @change="checkActive($event.target.checked)"
        >&nbsp;</a-checkbox
      >
    </a-form-item>
  </a-col>
</a-row>

You cannot set a form field before rendering a field associated with the value.

出现这个错误的原因:

  1. 没写 <a-form-item> 标签!
  2. fieldName写错了 this.form.setFieldsValue({ fieldName1: 0, fieldName2: [1, 2] });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions