Skip to content
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

input type=nickname获取小程序昵称 #12020

Closed
xiaochong44 opened this issue Jun 30, 2022 · 6 comments
Closed

input type=nickname获取小程序昵称 #12020

xiaochong44 opened this issue Jun 30, 2022 · 6 comments
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@xiaochong44
Copy link

相关平台

微信小程序

小程序基础库: 2.24.6
使用框架: Vue 3

复现步骤

input设置了 type=nickname 并设置了v-model绑定,在小程序里通过快捷方便填入昵称以后绑定的值没有变化,改用ref去获取控件的value属性也是空

期望结果

小程序里通过快捷方式填入昵称,绑定的值同步变化

实际结果

小程序里通过快捷方式填入昵称,绑定的值没有变化

环境信息

 Taro CLI 3.4.12 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD
@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jun 30, 2022
@alphardex
Copy link

可以用这个临时解法,不知啥时能修复

Taro.createSelectorQuery()
  .select("#nickname-input")
  .fields({
    properties: ["value"],
  })
  .exec((res) => {
    const nickname = res[0].value;
    // 处理nickname
  });

@Dr294769070
Copy link

uniapp版本

uni.createSelectorQuery().in(this) // 注意这里要加上 in(this)
    .select("#nickname-input")
    .fields({
        properties: ["value"],
    })
    .exec((res) => {
        const nickName = res?.[0]?.value
        console.log('昵称', nickName)
    })

@feiandxs
Copy link

过去这么久了仍然是使用这个方法解决的,thx

@ghost
Copy link

ghost commented Feb 19, 2023

您好,请问修复了吗

@Chen-jj
Copy link
Contributor

Chen-jj commented Jun 5, 2023

楼上没有提供 Demo,简单模拟了一下,Taro 最新版本中并没有复现(iPhoneX):

<template>
  <view>
    <input type="nickname" placeholder="nickname.." v-model="value" ref="inputRef">
    <view><text>value: {{ value }}</text></view>
    <button @tap="onClick">click me</button>
  </view>
</template>

<script setup>
  import Taro, { useReady } from '@tarojs/taro'
  import { ref } from 'vue'

  const value = ref('')
  const inputRef = ref()

  function onClick () {
    console.log('ref: ', inputRef.value.value)
  }
</script>

@Chen-jj Chen-jj closed this as completed Jun 5, 2023
@zhongzi
Copy link

zhongzi commented Feb 27, 2024

模拟也是通过ref取值,正常来说v-model不应该自动设值吗?🙏
目前测试结果如下图:zz 是原值,中仔 是微信名称,只有dom selector方式才能取到正确的值
vue: 3.4.19
taro: 3.6.23
weapp: 3.6.23

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

6 participants