vue-toasted icon indicating copy to clipboard operation
vue-toasted copied to clipboard

How to use with vue 3?

Open SaulMoonves opened this issue 4 years ago • 11 comments

help!

SaulMoonves avatar Oct 28 '20 02:10 SaulMoonves

I'd be interested also.

Edit: dist files are not up-to-date and need to be rebuild. The issue is that the build command is broken. There is an error about UglifyJsPlugin that can be solved by using the optimization.minimize config instead of this plugin.

However then I get other errors about vue-loader

vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

eino avatar Nov 03 '20 16:11 eino

If you need Vue 3 support, you might want to check out Vue Toastification v2, which offers similar features and native Vue 3 support.

Maronato avatar Nov 13 '20 14:11 Maronato

@shakee93 it's been a while can we get some sort of eta or a roadmap? Would really like to use this in my upcoming project, I've put off toasts for now but I'll have to implement them eventually.

terax6669 avatar Jan 20 '21 13:01 terax6669

Toasted works by extending the Vue.prototype. This breaks in Vue3, but you can work around it as follows:

const prevPrototype = Vue.prototype

Vue.prototype = {}

Vue.use(Toasted, {/*...*/})

Object.assign(Vue.config.globalProperties, Vue.prototype)

Vue.prototype = prevPrototype

chriscdn avatar May 25 '21 08:05 chriscdn

any news about vue 3 version?

volarname avatar Jan 19 '22 09:01 volarname

Hello, I am modifying the index.js file in line number 12 and now it works Screen Shot 2022-08-10 at 10 33 03 AM Vue.toasted = Vue.config.globalProperties.$toasted = Toast;

they must repackage the package

parrotsoft avatar Aug 10 '22 15:08 parrotsoft

Toasted works by extending the Vue.prototype. This breaks in Vue3, but you can work around it as follows:

const prevPrototype = Vue.prototype

Vue.prototype = {}

Vue.use(Toasted, {/*...*/})

Object.assign(Vue.config.globalProperties, Vue.prototype)

Vue.prototype = prevPrototype

This works 🎉

prd-y-nguyen avatar Aug 26 '22 08:08 prd-y-nguyen

One can use this one https://github.com/hoppscotch/vue-toasted

it has same API

ankurk91 avatar May 10 '23 06:05 ankurk91

This works for me:

// my injectToasted.js file
import Toasted from 'vue-toasted'
const TOASTED_OPTIONS = { className: 'toast', duration: 1000 }

export default function injectToasted (component, globalProperties) {
  const mockVue = {
    use (plugin, args) {
      plugin.install(this, args)
    },
    component
  }
  mockVue.prototype = {}
  mockVue.use(Toasted, TOASTED_OPTIONS)
  Object.assign(globalProperties, mockVue.prototype)
}

// my main.js file
...
const app = createApp(App)
injectToasted(app.component, app.config.globalProperties)
...

mkiselyow avatar Dec 24 '23 18:12 mkiselyow