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

补充双向绑定的测试用例 #1215

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zhzhch335
Copy link

测试用例中对双向绑定的测试仅测试了初始化阶段ref修改时<input/>文本框内容的变化,而如果在初始化之后主动修改ref的值,没有实现向<input/>的双向绑定的话,仍然会通过测试用例,因此补充一个初始化之后两秒主动修改ref的测试用例

举例,当前测试用例中,以下的代码可以通过:

const inputHandle = e => {
  value.value = e.target.value
}

const VOhModel = {
  mounted(el,bindings) {
    el.value = bindings.value
    el.addEventListener("input", inputHandle)
  },
  unmounted(el) {
    el.removeEventListener("input", inputHandle)
  }
}

const value = ref("Hello Vue.js")

setTimeout(() => {
  value.value = "Hello World!!!"
},2000)

但是两秒后,只有下方<p></p>标签中的值变为Hello World!!!,但是<input/>文本框内容没有变化,实际上并未完全实现双向绑定。

@netlify
Copy link

netlify bot commented Oct 11, 2022

Deploy Preview for vuejs-challenges ready!

Name Link
🔨 Latest commit ce980bd
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-challenges/deploys/634523da299f3a00090accbf
😎 Deploy Preview https://deploy-preview-1215--vuejs-challenges.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant