我现在有一个模板 <VerificationUser v-if="changePhoneData.popShow" v-show="changePhoneData.step === 2" :step-options="stepOptionsPC2" @fulfill="fulfillChangePhone($event)" @back="back" :loading="loading1" :key="2" buttonText="确认" msgType="UPDATE_MOBILE" > <div class="passwrod" slot="verify-before"> <van-field name="phone" v-model.trim="stepOptionsPC2.phone" validate-trigger="onBlur" :rules="[ { required: true, message: '请输入正确的手机号', pattern: patternPhone, }, ]" placeholder="请输入新的手机号" ></van-field> </div> </VerificationUser> 我想要在这个span打开它,应该改哪里 <div class="right" v-if="userinfo.authStatus == 1"> <span @click="nextStep" >查看实名</span> <img src="@/assets/img/棕色箭头-icon.png" alt="图片加载失败" /> </div>
时间: 2024-03-09 17:49:46 浏览: 71
你可以在 span 标签中添加一个 v-if 条件,当条件成立时渲染 VerificationUser 组件,如下所示:
```html
<div class="right" v-if="userinfo.authStatus == 1">
<span @click="changePhoneData.popShow = true" v-if="changePhoneData.step !== 2">修改手机号</span>
<VerificationUser
v-show="changePhoneData.step === 2"
:step-options="stepOptionsPC2"
@fulfill="fulfillChangePhone($event)"
@back="back"
:loading="loading1"
:key="2"
buttonText="确认"
msgType="UPDATE_MOBILE"
>
<div class="passwrod" slot="verify-before">
<van-field
name="phone"
v-model.trim="stepOptionsPC2.phone"
validate-trigger="onBlur"
:rules="[
{
required: true,
message: '请输入正确的手机号',
pattern: patternPhone,
},
]"
placeholder="请输入新的手机号"
></van-field>
</div>
</VerificationUser>
<img src="@/assets/img/棕色箭头-icon.png" alt="图片加载失败" />
</div>
```
这样,当用户点击“修改手机号”时,会将 changePhoneData.popShow 设置为 true,然后渲染 VerificationUser 组件。当用户完成修改手机号后,组件会被隐藏,回到原先的状态。
阅读全文