0

here is my code:

<template>
  <Frame actionBarVisibility="never"> 
    <Page @loaded="init()" backgroundSpanUnderStatusBar="true">

        <GridLayout ref="root" >
             <Label class="message" text="some text" />
        </GridLayout>

    </Page>
  </Frame>
</template>

and this:

<script lang="ts">

import { Vue, Component } from 'vue-property-decorator'

@Component
export default class Init extends Vue {
    init () {
       this.$refs.root.nativeView.backgroundColor = "#fff";
    }
}
</script>

the Problem:

ts complains about .nativeView after $refs :

Property 'nativeView' does not exist on type 'Vue | Element | Vue[] | Element[]'.

it seems that changing this.$refs.root to ( this.$refs.root as any ) solves the problem.

But is there any better approach? or could you please let me know why ts can Not apply .nativeView on the element (this.$refs.root) by himself?

4

0 回答 0