Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How main.js file can be edited in Nuxt.js?

I need to integrate ExtJS WebComponents with Nuxt.js. According to Sencha docs about integrating ExtJS with Vue.js I need to edit src/main.js file this way:

/*global Ext*/
import Vue from 'vue'
import App from './App.vue'
import '@sencha/ext-web-components/lib/ext-panel.component';

Ext.onReady(function() {
  new Vue({
    render: h => h(App)
  }).$mount('#app')
});

How can it be done in Nuxt.js?

like image 440
shpindler Avatar asked Sep 21 '19 07:09

shpindler


People also ask

Is NUXT JS frontend or backend?

js is a frontend framework built upon Vue. js that offers great development features such as server side rendering, automatically generated routes, improved meta tags managing and SEO improvement.

Where is Nuxt config file?

Nuxt Configuration config. ts file is located at the root of a Nuxt project and can override or extend the application's behavior.


1 Answers

You can easily do that with a plugin. I had the same problem with another package (about printing) and this is how I solved it:

1.In folder plugins, I created a file named printHtml.js containing:

import Vue from 'vue';
import VueHtmlToPaper from 'vue-html-to-paper';

Vue.use(VueHtmlToPaper);

2.Then in nuxt.config.js file i simply added:

  plugins: [
    '~plugins/printHtml.js'
  ],

And that's all. :) I was able to use the package functions in all components. You can do the same with ExtJS.

like image 68
nyagolova Avatar answered Nov 11 '22 16:11

nyagolova