34 lines
580 B
Vue
34 lines
580 B
Vue
<template>
|
|
<view class="p-t-300">
|
|
<button @click="submit()">提交</button>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import {
|
|
ref
|
|
} from 'vue';
|
|
|
|
const state = ref(false);
|
|
const formData = ref({
|
|
name: '内哥',
|
|
age: 10,
|
|
phone: null,
|
|
});
|
|
function submit() {
|
|
state.value = !state.value;
|
|
console.log('状态为:' + state.value);
|
|
if (state.value) {
|
|
formData.value.phone = '13800000000';
|
|
console.log('表单数据:', formData.value);
|
|
} else {
|
|
delete formData.value.phone;
|
|
console.log('表单数据:', formData.value);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|