uni-app 之 获取input输入内容
定义名称 v-model="logon_phone"
获取内容 console.log("111 111 logon_phone 打印 ", this.logon_phone)
<template>
<view style="width: 100%; display: flex; flex-direction:column; align-items:center;">
<view style="width: 60%; margin-top: 100px;">
<view style="display: flex; ">
<u-input placeholder="请输入手机号码" v-model="logon_phone" />
<button @click="getphoneurl">验证码</button>
</view>
<!-- <text>retCode={
{urlretCode}}; </text>
<text>retMsg={
{curlretMsg}}; </text> -->
</view>
</view>
</template>
<script>
export default {
data() {
return {
// urlretCode: "",
// curlretMsg: "",
logon_phone: "",
};
},
methods: {
// 按钮点击后执行的方法
getphoneurl() {
// uni.showLoading({
// title: "加载中" // 加个进度条
// })
console.log("----- phone打印 ", this.logon_phone)
uni.request({
url: "https://api.xxx.com/xxx/xxx/" + this.logon_phone,
success: res => {
console.log(res) // log打印获取的数据
// this.urlretCode = res.data.retCode
// this.curlretMsg = res.data.retMsg
// uni.hideLoading() // 加载出来后,关闭进度条
}
})
},
},
onLoad() {
// 页面刚进去就初始化的方法
// this.getphoneurl(),
}
}
</script>
<style lang="scss">
</style>