question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I install this package and:

<template>
  <no-ssr>
    <div style="height: 500px; width: 500px; border: 1px solid red; position: relative;">
      <vue-draggable-resizable :w="100" :h="100" v-on:dragging="onDrag" v-on:resizing="onResize" :parent="true">
        <p>Hello! I'm a flexible component. You can drag me around and you can resize me.<br>
        X: {{ x }} / Y: {{ y }} - Width: {{ width }} / Height: {{ height }}</p>
      </vue-draggable-resizable>
    </div>
  </no-ssr>
</template>

<script>
import VueDraggableResizable from 'vue-draggable-resizable'

export default {
  components: {
    VueDraggableResizable,
  },
  data () {
    return {
      width: 0,
      height: 0,
      x: 0,
      y: 0,
    }
  },
  methods: {
    onResize: function (x, y, width, height) {
      this.x = x
      this.y = y
      this.width = width
      this.height = height
    },
    onDrag: function (x, y) {
      this.x = x
      this.y = y
    },
  },
}
</script>

First reload of my page: image

Second reload: image

How can i use this package with nuxt? Tell me please.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mauriciuscommented, Nov 26, 2018

Sorry for the delay @nicothin. I made a PR to your repository fixing what I thought to be the problem. Check it out and let me know.

And I’d like to ask @mauricius to be so kind to clarify, does the plugin needs to be imported, if it already been used with Vue.use(require(‘vue-draggable-resizable’)).

@askhat actually this is not a plugin, but a component. Therefore it needs to be registered inside Vue by using the Vue.component('my-component-name', { ... }) notation.

1reaction
askhatcommented, Nov 25, 2018

@nicothin Nuxt provides an ability to plug in JS code that specifically relies on browser runtime with plugins functionality.

Shortly, you have to create a file inside the plugins directory, and call it for example vue-draggable-resizable.js. Then you need to populate it with imports and using:

import Vue from 'vue'
import VueDraggableResizable from 'vue-draggable-resizable'

Vue.use(VueDraggableResizable)

After file is made, all you have to is register plugin, you also have an option to forbid SSR for this plugin. Inside nuxt.config.js:

plugins: [{ src: '@plugins/vue-draggable-resizable', ssr: false }]

This is it, just make sure you do not use plugin in server side stages of component lifecycle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt - The Intuitive Vue Framework
Build your next Vue.js application with confidence using Nuxt. An open source framework making web development simple and powerful.
Read more >
Built-in Components - Nuxt
The <Nuxt> component is the component you use to display your page ... This component is used for displaying the children components in...
Read more >
Installation - Nuxt
Another way to get started with Nuxt is to use CodeSandbox which is a great way for quickly playing around with Nuxt and/or...
Read more >
Plugins directory - Nuxt
This is the place to add Vue plugins and to inject functions or constants. Every time you need to use Vue.use() , you...
Read more >
Commands and Deployment - Nuxt
Commands and deployment. Nuxt comes with a set of useful commands, both for development and production purpose. Using in package.json.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found