nativescript-vue: when using Vue.extend() the template block doesn't work

So instead of

export default {
   data
   methods
   ...
}

If I instead do

export default Vue.extend({
   data
   methods
   ...
})

Then the template is not loaded and I get You are running a runtime-only build of Vue warning. (Which is supposed to happen if template is string, or el is id, and no render function exists)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

Okay I have fixed this.

Here we go, how to use Typescript decorators with Vue

1. We need the original vue package for typedefs

npm install -D vue

But we don’t want to actually use vue in runtime

2. Make sure all vue imports are actually nativescript-vue imports

In your webpack config

alias: { 'vue$': 'nativescript-vue' }

3. Get class style decoration dependencies

npm install -D vue-property-decorator

4. Write class style components

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

@Component
export default class MyComponent extends Vue {
  count = 1
  increment () { this.count++ }
}