Comments (4)
The dom instance can't be fetched until after the mounted.
from core.
The dom instance can't be fetched until after the mounted.
主题已更新,改成这样也不行
from core.
The dom instance can't be fetched until after the mounted.
主题已更新,改成这样也不行
from core.
vue3中,想用ts类来开发组件,现在遇到个问题,如何定义ref,代码如下,this.dom.value在方法中为null
--------test.ts-------- import { Ref, h, ref } from 'vue' export default class MyClass { private name: string private dom: Ref = ref(null) //构造函数 constructor() { this.name = 'test' } public initHtml() { return h('div', { ref: this.dom }, this.name) } public page() { console.log('------880-------', this.dom.value) } }
调用示例
--------my.tsx-------- import { defineComponent, onMounted } from 'vue' import MyClass from './test' export default defineComponent({ setup() { const vs = new MyClass() onMounted(() => { vs.page() }) return () => vs.initHtml() }, })
改成上面这样就行了
from core.
Related Issues (20)
- Not possible to use Symbol values for checkbox v-model values HOT 3
- Change in computed property behavior with Reactive objects in 3.4 HOT 3
- `app.provide` is not type safe
- UModal error when opened HOT 1
- Invalid bidirectional binding of subcomponent ref HOT 2
- Cannot read properties of null (reading 'insertBefore') HOT 2
- Vue compat with Jest: "TypeError: decode_js.EntityDecoder is not a constructor" HOT 2
- MutationObserver in defineCustomElement is disconnected if we move the custom element to another place, then lose attribute observation
- Input with type="number" does not update value after removing leading zeros from v-model binding HOT 1
- Formerly functional project is now broken HOT 2
- KeepAlive + Transition + v-if 同时使用时会导致时会导致内存泄漏的2个bug HOT 6
- Cannot dynamically assign new property to $options object in vue/compat
- Vue defineProps<> can't use imported Interface HOT 6
- Agree with you. For vue2 I am going to have an issue no ? how can I an make both working good ? HOT 2
- Incorrect type error with kebab-cased "aria-*" props HOT 4
- 导入类型时省略.tsx后缀,在defineProps<>中使用导入的类型,会提示Failed to resolve import source "xxxx" HOT 4
- Two-way binding not working when using reactive, must use Ref HOT 6
- Computed generic type stripping ruin the type strictness HOT 1
- Using generic component with typed slots (defineSlots) in non-setup component breaks types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.