vue-sweetalert2
vue-sweetalert2 copied to clipboard
I want to bind html as vue-component
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~!
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
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
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
yes, that is why i use function initForm and getResult as the bridge.