flore2003 / nativescript-markdown-view

A NativeScript plugin that provides a natively rendered markdown view
MIT License
18 stars 7 forks source link

How to use with nativescript-vue ? #17

Open Astriaporta opened 4 years ago

Astriaporta commented 4 years ago

Is there an example of use with nativescript-view? I tried to import it into a component as an element but it doesn't work.

kaisten commented 3 years ago

yes you have to register the Plugin in the vue environment. Here is a example how I use it

Vue.registerElement( 'MdView', () => require('nativescript-markdown-view').MarkdownView )

PixsaOJ commented 1 year ago

Vue.registerElement('MdView', () => new MarkdownView()) Same error message with kaisten's method

 {NSVue (Vue: 2.6.14 | NSVue: 2.9.2)} -> CreateElement(mdview)
  JS: TypeError: Could not load view for: nativemdview. TypeError: Class constructor TextView cannot be invoked without 'new' TypeError: Class constructor TextView cannot be invoked without 'new'
  JS:     at MarkdownViewBase [as constructor] (file: app/webpack:/cnick-app/node_modules/.pnpm/nativescript-markdown-view@2.0.0/node_modules/nativescript-markdown-view/markdown-view.common.js:8:0)
  JS:     at new MarkdownView (file: app/webpack:/cnick-app/node_modules/.pnpm/nativescript-markdown-view@2.0.0/node_modules/nativescript-markdown-view/markdown-view.android.js:9:0)
  JS:     at Object.resolver (file: app/webpack:/cnick-app/app/app.ts:24:30)
  JS:     at getViewClass (file: app/webpack:/cnick-app/node_modules/.pnpm/nativescript-vue@2.9.2/node_modules/nativescript-vue/dist/index.js:7603:0)
  JS:     at new ElementNode (file: app/webpack:/cnick-app/node_modules/.pnpm/nativescript-vue@2.9.2/node_modules/nativescript-vue/dist/index.js:8466:0)
  JS:     at Function.createElement (file: app/webpack:/cnick-app/node_modules/.pnpm/nativescript-vue@2.9.2/node_modules/nativescript-vue/dist/index.js:8578:0)
  JS:     at Object.createElement (file: app/webpack:/cnick-app/node_modules/.pnpm/nativescript-vue@2.9.2/node_modules/nativescript-vue/dist/index.js:8607:0)
  JS:     at createElm (file: app/webpack:/cnick-app/node_modules/.pnpm/nativescript-vue@2.9.2/node_modules/nativescript-vue/dist/index.js:5297:0)
  JS:     at createChildren (file: app/webpack:/cnick-app/node_modules/.pnpm/nativescript-vue@2.9.2/node_modules/nativescript-vue/dist/index.js:5401:0)
  JS:     at createElm (file:///data/dat...
  JS: [Navigator] Failed to navigate: TypeError: Cannot read property 'setAttribute' of undefined

I always get TypeError: Class constructor TextView cannot be invoked without 'new'