avil13 / vue-sweetalert2

A convenient wrapper for sweetalert2.
https://avil13.github.io/vue-sweetalert2/
653 stars 75 forks source link

I want to bind html as vue-component #59

Open kunJuly opened 5 years ago

kunJuly commented 5 years ago

like this this.$swal({ type: 'success', target: document.getElementsByClassName('live-left')[0], // text: 'hellllllll', html: <PopupWindow></PopupWindow> })

PopupWindow is my component

Can I do that?thank~!

panudetjt commented 5 years ago

I want a solution to this problem either. After I googling it I found the solution it's work if we don't use this package like in this fiddle

but If we use this package in the swal content we will get this

<!--function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }-->

Why does that happen?

ref: https://stackoverflow.com/questions/48683390/using-vue-component-in-sweetalert2-content

fahmizulhasymi commented 5 years ago

After some digging, i found related post to the stackoverflow link from @panudetjt

for my case, i need to create interactive Vue Form. and i use this package so much in my apps.

This is what i came up with. live sample here

i create component Instances programmatically, and mount it everytime i need the form (in case there is some preprocess). and get form result before i destroy it.

ref: v-model on component

LeonAlvarez commented 4 years ago

After some digging, i found related post to the stackoverflow link from @panudetjt

for my case, i need to create interactive Vue Form. and i use this package so much in my apps.

This is what i came up with. live sample here

i create component Instances programmatically, and mount it everytime i need the form (in case there is some preprocess). and get form result before i destroy it.

ref: v-model on component

The problem with that solution is that it will be another Vue instance so, if you are using for example vuex you won't have access to it there

fahmizulhasymi commented 4 years ago

yes, that is why i use function initForm and getResult as the bridge.