当我读取渲染函数的数据时:https://v2.vuejs.org/v2/guide/render-function.html#The-Data-Object-In-Depth
没有v-model
的地方,v-model
在Vue.js 2.0中不存在。
下面是官网给的数据例子,但是没有说v-model
放置:
{
// Same API as `v-bind:class`
class: {
foo: true,
bar: false
},
// Same API as `v-bind:style`
style: {
color: 'red',
fontSize: '14px'
},
// Normal HTML attributes
attrs: {
id: 'foo'
},
// Component props
props: {
myProp: 'bar'
},
// DOM properties
domProps: {
innerHTML: 'baz'
},
// Event handlers are nested under `on`, though
// modifiers such as in `v-on:keyup.enter` are not
// supported. You'll have to manually check the
// keyCode in the handler instead.
on: {
click: this.clickHandler
},
// For components only. Allows you to listen to
// native events, rather than events emitted from
// the component using `vm.$emit`.
nativeOn: {
click: this.nativeClickHandler
},
// Custom directives. Note that the `binding`'s
// `oldValue` cannot be set, as Vue keeps track
// of it for you.
directives: [
{
name: 'my-custom-directive',
value: '2',
expression: '1 + 1',
arg: 'foo',
modifiers: {
bar: true
}
}
],
// Scoped slots in the form of
// { name: props => VNode | Array<VNode> }
scopedSlots: {
default: props => createElement('span', props.text)
},
// The name of the slot, if this component is the
// child of another component
slot: 'name-of-slot',
// Other special top-level properties
key: 'myKey',
ref: 'myRef'
}
你看有很多key,比如ref
,key
,props
等等,我怎么实现这个需求?
最佳答案
props: {
myProp: 'bar',
value: 'someValue'
},
on: {
click: this.clickHandler,
input: function(value) {
// change someValue here using value
},
},
关于vue.js - 如何在渲染函数中实现 `v-model`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49810784/