
https://qiita.com/MariMurotani/items/5fbea5942d2edf149989
↑上を参考にvueの勉強をしています...
router-viewのルートに配置されたコンポーネントでjqueryを使いたいです
javascript
1//Scene1.vue 2 3<template> 4 <div class="Scene1" id="Scene1"> 5 <div @click="goFooter">下へ</div> 6 7 <div class="contents"></div> 8 9 <div class="footer" id="footer">あいう</div> 10 </div> 11</template> 12 13<script> 14 15//import { $ } from "jquery" ← こうじゃなくて 16 17import jQuery from "jquery" 18global.$ = jQuery //このようにする 19 20 21export default { 22 name: 'Scene1', 23 methods:{ 24 showMessage: function(){alert(this.msg)}, 25 goFooter: function(){ 26 $("#Scene1").scrollTop($("#footer").scrollTop()); 27 } 28 } 29} 30</script> 31 32<!-- Add "scoped" attribute to limit CSS to this component only --> 33<style scoped> 34 35.Scene1{ 36 background: gray; 37 width: 100vw; 38 //height: 200vh; 39 height: 10vh; 40 //position: relative; 41 overflow: scroll; 42} 43 44.contents{ 45 width: 5vw; 46 height: 100vh; 47 background: white; 48} 49 50.footer{ 51 //position: absolute; 52 //bottom: 0px; 53} 54 55</style> 56 57
「下へ」をクリックすると
Uncaught TypeError: Object(...) is not a function
at VueComponent.goFooter (Scene1.vue?584a:33)
at invoker (vue.esm.js?efeb:2027)
at HTMLDivElement.fn._withTask.fn._withTask (vue.esm.js?efeb:1826)
とエラーが出てしまい、下へスクロールしてくれません...
調べてみたのですが分からなくて(T___T)
上のshowMessageなどは動きます
どうすればいいのでしょうか

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。