The Wayback Machine - https://web.archive.org/web/20250228191700/https://github.com/vuejs/vue-class-component/issues/495
Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

I cann't bind the ref data to dom node. what should i do? #495

Copy link
Copy link
Closed
@ChainsDW

Description

<template>
  <div class="app-content">
    <div class="content-search">
      <el-input ref="inputCun.search" class="search-input" placeholder="请输入内容" @keypress.enter="inputCun.handleSearch"></el-input>
    </div>
    <div></div>
  </div>
</template>

<script lang="ts">
import Super from '@/public/mixin.ts'
import { ref, onMounted } from 'vue'
import { Options, setup } from 'vue-class-component'

const bindDom = () => {
  const search = ref(null)
  onMounted(() => {
    console.log(search.value)
    // watchEffect(()=>{
    //   console.log(stateDom.value)
    // })
  })
  const handleSearch = () => {
    console.log(search)
  }
  return { search, handleSearch }
}

@Options({
  components: {
  }
})
export default class Dashboard extends Super {
  inputCun = setup(() => bindDom())
}
</script>

<style scoped lang="stylus">
.app-content
  .content-search
    height 300px
    display flex
    justify-content center
    align-items center
    .search-input
      width 40vw
      min-width 130px
</style>

ref="inputCun.search" doesn't work

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.