Comments (7)
I have a solution for
[Vue warn]: Error in v-on handler: "TypeError: $event.stopPropagation is not a function"
The problem is that "@click" events are often non-native, when emitted from custom components. Hence, $event does not have a stopPropagation function anymore.
Solution: instead of writing this.$emit('click', myData)
write
event.data = myData
this.$emit('click', event)
This should work if event
is a native click event.
If not, then try and go up one level.
Suggestion for fullscreen devs:
If fullscreen does have a @click event then it is a nicer api to provide the native click event so the users can use @click.stop as expected.
from vue-fullscreen.
@BarnabasSzabolcs Thanks so much for documenting your solution. We were migrating a component using a custom click event from Vue 2 to Vue 3 and ran into this exact error, and passing the native click event worked like a charm 💯
from vue-fullscreen.
I need more info to find out the problem, it is better to provide an online example, like this:
https://codepen.io/mirari/pen/vjzXJN
I think it might be ImageModal
's problem, find the context for $event
from vue-fullscreen.
Can not reproduce
https://codepen.io/asdasdddd/pen/jOEzojj
Maybe because we do not use vue-modal package?
We do not use a vue-modal package, own simple div with state isHidden.
https://codepen.io/asdasdddd/pen/jOEzojj
When modal opened, it contains an image only and 2 buttons, toggle fullscreen and close modal
As you can see custom Vue directive handles click outside the image to toggle modal, hide the image.
In our case, toggle fullscreen is outside of the image.
Error is thrown, this is from local env.
{
ref: "fullscreen",
on: {
change: function($event) {
$event.stopPropagation()
return _vm.fullscreenChange($event)
}
}
},
It seems we missing something.
// ERROR
<fullscreen @change.stop="fullscreenChange"
// SUCCESS modal window closed because click is outside of image!
<fullscreen @change="fullscreenChange"
// SUCCESS modal window closed because click is outside of image!
<fullscreen :fullscreen.sync="isFullScreen"
from vue-fullscreen.
Solved this way
<fullscreen @change="fullscreenChange"
...
<em @click.stop="hideModalWindow($event)" />
...
v-click-outside="hideModalWindow"
...
hideModalWindow (event) {
if ('EM' !== event.srcElement.tagName) {
this.hideModal();
}
},
from vue-fullscreen.
I have a solution for
[Vue warn]: Error in v-on handler: "TypeError: $event.stopPropagation is not a function"
The problem is that "@click" events are often non-native, when emitted from custom components. Hence, $event does not have a stopPropagation function anymore.
Solution: instead of writing
this.$emit('click', myData)
writeevent.data = myData this.$emit('click', event)
This should work if
event
is a native click event. If not, then try and go up one level.Suggestion for fullscreen devs:
If fullscreen does have a @click event then it is a nicer api to provide the native click event so the users can use @click.stop as expected.
The way to modify custom components is not a universal approach.
I think you should use @click.native.stop
.
from vue-fullscreen.
Your suggestion looked promising, @mirari . I have tried it for my situation right away and it does not work. The reason may be that emitted custom events do not have any native events behind them.
No worries otherwise I don't use vue-fullscreen, I just posted my suggestion since it solves the problem of the OP.
Best of luck,
Barney
from vue-fullscreen.
Related Issues (20)
- 建议把点击就退出的功能在option中加一个开关 HOT 2
- Compile vue-fullscreen with application HOT 6
- iPhone Full Screen doesnot work HOT 2
- Compatibility with Jest HOT 2
- Are there plans to support VUE3 HOT 9
- window.onscroll does not work in fullscreen mode HOT 1
- 全屏下的input聚焦输入时会退出全屏怎么处理 HOT 2
- Failed when publish HOT 1
- antv x6的拖拽wrapper和 elementui 的message弹框依旧会被盖住哦 HOT 3
- 全屏元素含iframe时,teleport设置为啥都有bug HOT 6
- Component does not destroy its childrem when Unmount HOT 1
- vue 转 app 返回时会退出全屏 HOT 1
- Retain fullscreen on redirect HOT 2
- Failed to execute 'insertBefore' on 'Node': The new child element contains the parent HOT 2
- Do not work on iOS HOT 1
- 如何快速给element-ui的组件添加右上角全屏显示图标按钮和功能?
- Feature request: exit manually HOT 12
- vue3注册插件时报错 HOT 2
- Vue3.main.js 组件注册,抛出error HOT 1
- Inconsistent licensing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-fullscreen.