-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
vnode not work for functional from v2.5.14 #7799
Comments
@yyx990803 |
Mentioning Evan will not get your help faster, we read every issue and priorize all issues accoring to the grater needs of Vue and the ecosystem. |
By using Although that usage worked in previous version, I recommend to use a more standard way: Vue.component('value-vnode', {
functional: true,
render: (h, { props }) => props.value
})
<div>
<op-vnode :value="$slots.default"/>
</div> |
hhm, not sure you should pretty much what @jkzing said (as I was writing this before his comment got published 😆 ) |
OP's usage should be covered in #7765. For more board usage, should we support On the other hand, returning a non vnode data in render function doesn't make much sense. It might invalidate JS engine's type speculation, which might harm runtime performance(not sure). |
@jkzing |
Actually I'm pretty agree with @HerringtonDarkholme, that render function should return only vnode data. As returning non vnode object was working in previous version, a warning would be more reasonable than a fix? |
@jkzing what is v-bind mean ? |
Sadly that's not how Vue works at all. Vue's vnode has two On the other hand, React flavor's JSX only have one props. So passing object as is makes sense. |
@HerringtonDarkholme |
Well, you don't get to define what |
@HerringtonDarkholme @jkzing @LinusBorg |
if it is a breaking change, |
It was never intended to work, so no, it's not a breaking change
Now that, on the other hand, would be a very big breaking change, because props named |
@LinusBorg |
Ringt Now I still don't see what we should fix, since what you did should not have worked in the first place, as far as I can tell so far. So no, as far as I understand right now, I don't see anything to "fix", but maybe we find a way to improve the behaviour. We could also document this a bit better if no improve men can be found. |
@LinusBorg |
@yozman, I already gave you a proper usage above, which is: |
@jkzing |
@jkzing |
There's no need to be swearing. I will simply lock the issue if you can't discuss in a civil manner. |
That's not If you really persist in using Vue.component('op-vnode', {
functional: true,
render: (h, { props }) => props.node,
});
Vue.component('op-row', {
template: `
<div>
<template v-for="(item, index) in $slots.default">
<span v-if="index">></span>
<op-vnode v-bind="{ node: item }" />
</template>
</div>
`,
}); |
|
got it, sorry for my bad words |
@LinusBorg @jkzing @yyx990803
import OpButton from '../op-button';
import OpCol from '../op-col';
import OpForm from '../op-form';
import OpRow from '../op-row';
import OpVnode from '../op-vnode';
import slots from '../../src/mixins/slots';
const template = /*html*/`
<op-form>
<op-row v-for="(row, rowIndex) in grid" :key="rowIndex" :gutter="70" align="bottom" type="flex">
<op-col v-for="(col, colIndex) in row" :key="colIndex" :span="6">
<template v-if="col.name === 'control'">
<op-vnode v-for="(control, index) in col" :key="index" :clone="control"/>
<template v-if="slots().length > 7">
<op-button type="text" @click="expanded = !expanded" :style="{ 'margin-top': '16px' }">{{ expanded ? '收起' : '展开' }}</op-button>
</template>
</template>
<op-vnode v-else :clone="col"/>
</op-col>
</op-row>
<b hidden><slot/></b>
</op-form>
`;
export default {
template,
components: {
OpButton,
OpCol,
OpForm,
OpRow,
OpVnode,
},
mixins: [slots],
data: () => ({
expanded: false,
}),
computed: {
grid: ({ expanded, getGrid, slots: _slots }) => getGrid(
_slots().reduce(getGrid, []),
_slots('control'),
expanded ? _slots().length : Math.min(_slots().length, 7) % 4,
),
},
methods: {
getGrid(arr, item, index) {
if (!this.expanded && index >= 7) return arr;
if (index % 4 === 0) return [...arr, [item]];
arr[arr.length - 1].push(item);
return arr;
},
},
}; as I know import OPUI from '@wnpm/op-ui';
const template = /*html*/`
<div>
<op-breadcrumb separator="/">
<op-breadcrumb-item>首页</op-breadcrumb-item>
<op-breadcrumb-item>YDC</op-breadcrumb-item>
<op-breadcrumb-item>查询表格</op-breadcrumb-item>
</op-breadcrumb>
<op-card>
<h2 slot="out-header">任务分组</h2>
<op-query-form>
<template slot="control">
<op-button type="primary">查询</op-button>
<op-button>清空</op-button>
</template>
<op-form-item label="销售地点">
<op-input placeholder="请填写"/>
</op-form-item>
<op-form-item label="销售地点">
<op-input placeholder="请填写"/>
</op-form-item>
<op-form-item label="销售地点">
<op-input placeholder="请填写"/>
</op-form-item>
<op-form-item label="销售地点">
<op-input placeholder="请填写"/>
</op-form-item>
<op-form-item label="销售地点">
<op-select v-model="select">
<op-option value="北京市朝阳区"/>
<op-option value="北京市海淀区"/>
<op-option value="北京市东城区"/>
</op-select>
</op-form-item>
<op-form-item label="销售地点">
<op-date-picker v-model="date"/>
</op-form-item>
<op-form-item label="销售地点">
<op-time-picker v-model="time"/>
</op-form-item>
<op-form-item label="销售地点">
<op-input placeholder="请填写"/>
</op-form-item>
<op-form-item label="销售地点">
<op-input placeholder="请填写"/>
</op-form-item>
<op-form-item label="销售地点">
<op-input placeholder="请填写"/>
</op-form-item>
<op-form-item label="销售地点">
<op-input placeholder="请填写"/>
</op-form-item>
</op-query-form>
</op-card>
</div>
`;
const component = {
template,
components: {
...OPUI,
},
data: () => ({
fullscreen: false,
select: '',
date: '',
time: '',
}),
};
export default {
component,
path: 'list',
}; when change |
@yozman please open a separate issue with proper reproduction. This thread is not your personal support line. |
Version
2.5.15
Reproduction link
https://codepen.io/yozman/pen/JLdaRZ
Steps to reproduce
the codepen is a demo for v2.5.13,
it's works well,
when change to v2.5.14 or v2.5.15,
there is blank output
What is expected?
work well as v2.5.13
What is actually happening?
blank output
The text was updated successfully, but these errors were encountered: