Bonjour, je suis entrain de me former en VUE JS (2) et j'ai un problème :
j'aimerai faire un input avec un bouton, et récupérer la valeur de l'input quand je valide le bouton
j'ai cette erreur lors du chargement de la page
Voici mon fichier "main.js"vue.runtime.esm.js?2b0e:587 [Vue warn]: Property or method "edit" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivit...ive-Properties.
found in
---> <Geoloc> at src/Geo.vue
<Root>
warn @ vue.runtime.esm.js?2b0e:587
vue.runtime.esm.js?2b0e:587 [Vue warn]: Invalid handler for event "click": got undefined
found in
---> <Geoloc> at src/Geo.vue
<Root>
et voila le fichier concerné Geo.vue
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 import Vue from 'vue' import Geo from './Geo.vue' import Footer from './Footer.vue' import Header from './Header.vue' new Vue({ render: h => h(Header) }).$mount('#header') new Vue({ el: '#geoloc', data: { lat: '', lon: '' }, render: h => h(Geo), methods: { geolocation() { navigator.geolocation.getCurrentPosition(this.buildUrl, this.geoError); }, buildUrl(position) { this.lat = position.coords.latitude; this.lon = position.coords.longitude; console.log(this.lat); console.log(this.lon); }, geoError(error) { alert(error); }, edit () { console.log("ok") } }, beforeMount() { this.geolocation(); }, }) new Vue({ render: h => h(Footer) }).$mount('#footer')
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 <template> <section id="wrapp-geolocation"> <div @click="edit">FOO</div> </section> </template> <script> export default { name: 'Geoloc' } //import { TodoList } from './components/todo.js'; </script> <style> #wrapp-geolocation { margin-top: 70px; } </style>
Pouvez vous m'aider ?
merci d'avance, je ne comprends pas pourquoi rien ne se passe quand je clique sur le div
Partager