Comments (21)
请问:
$r和$f都是什么啊 在哪里定义的呢
from form-create.
我不定义会报错
from form-create.
使用前要Vue.use(formCreate)
;
from form-create.
然后在vue内部,比如
mounted:function(){
//rule 是表单规则
//options是全局配置,可以不传
//$r是api方法的对象
$r = this.$formCreate(rule,options);
}
from form-create.
<!-- import Vue ^2.5.16-->
<script src="node_modules/vue/dist/vue.min.js"></script>
<!-- import iview ^2.13.0-->
<link rel="stylesheet" href="node_modules/iview/dist/styles/iview.css">
<script src="node_modules/iview/dist/iview.min.js"></script>
<!-- import formCreate -->
<script src="dist/form-create.min.js"></script>
已上是必须引入的
<!-- 省市区三级联动json数据 使用省市区三级联动时引入-->
<script src="/district/province_city_area.js"></script>
<!-- 模拟数据 demo中的表单规则 -->
<script src="mock.js"></script>
from form-create.
$formCreate.make
指的是 vue内部的this.$formCreate.maker
或者 window.formCreate.maker
文档中没有说清楚不好意思
from form-create.
你说的这些刚才我依然解决了
import formCreat from 'form-create'
import iView from 'iview';
import 'iview/dist/styles/iview.css';
Vue.use(iView);
Vue.use(formCreat)
我是这么搞的
现在有些问题还需要请教一下
$f和$r我现在理解为实例
this.$formCreate(this.$formCreate.maker,this.options);
我只需要写入这一句话,按理说所以的标签都会显示在我的页面上,对吧?
但是目前只显示一个button提交,其他均不显示,
难倒我挂载错了?
还有个奇怪的现象就是,不管我挂在到哪个id上,甚至不挂载为null都只显示一个button,
求,答疑解惑
from form-create.
我的代码如下
`let root = document.getElementById('demo'),that = this;
this.options.el = root
let $f = this.$formCreate(this.$formCreate.maker,this.options);`
from form-create.
options是复制你的一点没变,然后放进了data里 只是通过this.options.el来改变需要挂载的id
from form-create.
我打印了this.$formCreate.maker
说明这个是所有页面元素的规则,按理说会显示所有的
还有就是 $f 和 $r我这边this里边获取不到 你说的api方法,难倒我们不需要定义吗?
这样 $r = this.$formCreate(rule,options);
还是这样let $r = this.$formCreate(rule,options);
虽然我在main.js里使用了Vue.use
from form-create.
this.$formCreate.maker
是表单规则生成器,你需要用它生成你表单的具体规则,你看下README后面有介绍
from form-create.
表单成功生成出来了吗?
from form-create.
我的写法如下
let root = document.getElementById('demo'),that = this;
this.options.el = root
let rule = this.$formCreate.maker.input("商品名称","goods_name","iphone 7").props({
clearable:true,
placeholder: "请输入商品名称"
}).validate([
{ required: true, message: '请输入goods_name', trigger: 'blur' },
])
let $f = this.$formCreate(rule,this.options);
from form-create.
显示不出来
from form-create.
正确写法
this.$formCreate([
this.$formCreate.maker.input("商品名称","goods_name","iphone 7").props({
clearable:true,
placeholder: "请输入商品名称"
}).validate([
{ required: true, message: '请输入goods_name', trigger: 'blur' },
])
],{
el:document.getElementById('demo')
})
from form-create.
hi, bro i need you, i will study your product deeply
from form-create.
ok, it has worked
from form-create.
如果想展示全部
需要单独引入一下
import 'form-create/mock.js'
然后在mounted里写入
this.$formCreate(window.mock,{
el:document.getElementById('demo')
})
就ok了 当然了有个地方报错,估计还需要引入三级联动的什么东西,我再看看,这个主要是写个后来者看的
from form-create.
mock只是个示例,你可以根据自己的需求生成表单
<!-- 省市区三级联动json数据 -->
<script src="/district/province_city_area.js"></script>
from form-create.
vue工程的引入顺序如下
import formCreat from 'form-create'
import 'form-create/district/province_city_area.js'
import 'form-create/mock.js'
import iView from 'iview';
import 'iview/dist/styles/iview.css';
Vue.use(iView);
Vue.use(formCreat)
其中前三个的引入顺序不能变,否则会有三级联动不显示,或者报错的现象
from form-create.
ok
from form-create.
Related Issues (20)
- package.json 中 "bili": "cross-env bili" 这个是啥意思?
- 自定义组件的表单验证,清空自定义组件的值,需要点击提交才能显示必填提示 HOT 2
- 000 HOT 2
- 来自elementui 的radio 的warn HOT 2
- import
- 在ElMessageBox中使用h函数使用FormCreate,element-ui 是不是不能使用autoimport?
- 表单提交问题 HOT 2
- 兼容问题 HOT 2
- info 需要更加灵活的配置 HOT 1
- 多组件联合联动,组件一的值+组合二的值 控制显示不同组件 如何弄 HOT 2
- 数组组件如何修改字段 HOT 9
- Select组件使用Effect获取数据后,在Update中无法获取Options HOT 2
- fApi.getRule is not a function HOT 1
- 有没有配置在提交数据时不获取field对应的值 HOT 1
- 如果一个对象是一个MAP, 键值都不知道, 这个时候他的RULE要怎么定义 HOT 2
- 文档官网打不开了 HOT 2
- adv@4 版本,type为textarea 时,fApi.resetFields()无效 HOT 2
- FormCreate放到 a-modal 弹框中时,resetFields 无效 HOT 1
- 使用iframe嵌入拖拽失效
- 上传组件成功方法里无法使用异步操作
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from form-create.