types: improve ref typing

This commit is contained in:
chenjiahan 2020-10-09 19:51:43 +08:00
parent eda4de93ae
commit 683cc88c54
2 changed files with 3 additions and 3 deletions

View File

@ -31,7 +31,7 @@ export default defineComponent({
emits: ['click', 'toggle'],
setup(props, { emit, slots }) {
const iconRef = ref();
const iconRef = ref<HTMLElement>();
const getParentProp = (name: string) => {
if (props.parent) {
@ -60,7 +60,7 @@ export default defineComponent({
const onClick = (event: MouseEvent) => {
const { target } = event;
const icon = iconRef.value;
const iconClicked = icon === target || icon.contains(target);
const iconClicked = icon === target || icon!.contains(target as Node);
if (!disabled.value && (iconClicked || !props.labelDisabled)) {
emit('toggle');

View File

@ -39,7 +39,7 @@ export default createComponent({
setup(props, { emit, slots }) {
const error = ref(false);
const loading = ref(true);
const imageRef = ref();
const imageRef = ref<HTMLElement>();
const style = computed(() => {
const style: CSSProperties = {};