mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: add warn of deprecated slot (#8972)
* chore: migrate cell default slot * chore: add warn of deprecated slot
This commit is contained in:
parent
bc8bad0247
commit
b3ca94dfad
@ -33,7 +33,7 @@ export const cellProps = {
|
|||||||
valueClass: unknownProp,
|
valueClass: unknownProp,
|
||||||
labelClass: unknownProp,
|
labelClass: unknownProp,
|
||||||
titleClass: unknownProp,
|
titleClass: unknownProp,
|
||||||
titleStyle: null as unknown as PropType<string | CSSProperties>,
|
titleStyle: (null as unknown) as PropType<string | CSSProperties>,
|
||||||
arrowDirection: String as PropType<CellArrowDirection>,
|
arrowDirection: String as PropType<CellArrowDirection>,
|
||||||
clickable: {
|
clickable: {
|
||||||
type: Boolean as PropType<boolean | null>,
|
type: Boolean as PropType<boolean | null>,
|
||||||
@ -47,6 +47,14 @@ export default defineComponent({
|
|||||||
props: extend({}, cellProps, routeProps),
|
props: extend({}, cellProps, routeProps),
|
||||||
|
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
if (slots.default) {
|
||||||
|
console.warn(
|
||||||
|
'[Vant] Cell: "default" slot is deprecated, please use "value" slot instead.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const renderLabel = () => {
|
const renderLabel = () => {
|
||||||
|
@ -12,14 +12,6 @@ exports[`should change icon class prefix when using icon-prefix prop 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should render default slot correctly 1`] = `
|
|
||||||
<div class="van-cell">
|
|
||||||
<div class="van-cell__value van-cell__value--alone">
|
|
||||||
Custom Value
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`should render extra slot correctly 1`] = `
|
exports[`should render extra slot correctly 1`] = `
|
||||||
<div class="van-cell">
|
<div class="van-cell">
|
||||||
Custom Extra
|
Custom Extra
|
||||||
|
@ -1,15 +1,6 @@
|
|||||||
import { Cell } from '..';
|
import { Cell } from '..';
|
||||||
import { mount } from '../../../test';
|
import { mount } from '../../../test';
|
||||||
|
|
||||||
test('should render default slot correctly', () => {
|
|
||||||
const wrapper = mount(Cell, {
|
|
||||||
slots: {
|
|
||||||
default: () => 'Custom Value',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should render value slot correctly', () => {
|
test('should render value slot correctly', () => {
|
||||||
const wrapper = mount(Cell, {
|
const wrapper = mount(Cell, {
|
||||||
slots: {
|
slots: {
|
||||||
|
@ -92,6 +92,12 @@ export default defineComponent({
|
|||||||
emits: ['confirm', 'cancel', 'change'],
|
emits: ['confirm', 'cancel', 'change'],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
|
if (slots.default) {
|
||||||
|
console.warn(
|
||||||
|
'[Vant] Picker: "default" slot is deprecated, please use "toolbar" slot instead.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const formattedColumns = ref<PickerObjectColumn[]>([]);
|
const formattedColumns = ref<PickerObjectColumn[]>([]);
|
||||||
|
|
||||||
const { text: textKey, values: valuesKey, children: childrenKey } = extend(
|
const { text: textKey, values: valuesKey, children: childrenKey } = extend(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user