Vue.jsを使ってナビゲーションドロワーをサイトに実装しようと思っているのですが、うまく動作せずに以下の画像のようになってしまっています。
ちなみに黄色の①が開閉用のボタン、②がボタンを押した時に表示させたいメニュー部分です。
※単体でその部分をjsfiddleで動かしてみる分には問題なく動作しました。
https://jsfiddle.net/6b1749fd/
そしてコンソールで表示されたエラー内容は
Uncaught TypeError: Cannot read property 'default' of undefinedat script.js:1
で、 下記のJavaScritpのコードの一行目の「vue-js-modal」の読み込みでエラーになっているようです。
皆様、お力添えくださいますようお願い申し上げます。
以下がヘッダー部分のコードになります。
html
1<header> 2 <div class="header-navi"> 3 <div class="menu-button" v-on:click="toggleMenu"> 4 <i class="fas fa-align-justify" v-show="!showMenu"></i> 5 <i class="fas fa-times" v-show="showMenu"></i> 6 </div> 7 <img src="img/mylogo.png"> 8 <nav> 9 <ul> 10 <li><a href="index.html">TOP</a></li> 11 <li><a href="about.html">ABOUT</a></li> 12 <li><a href="skills.html">SKILLS</a></li> 13 <li><a href="works.html">WORKS</a></li> 14 </ul> 15 </nav> 16 </div> 17 <transition name="menu"> 18 <div class="menu" v-show="showMenu"> 19 <p> 20 メニューの内容 21 </p> 22 </div> 23 </transition> 24 <div id="pseudo-element"> 25 <!-- margin調整用 --> 26 </div> 27 <h1>Taku's</h1> 28 <h2>portfolio site</h2> 29 <p>Welcome to my site!</p> 30 <div class="down-button"> 31 <a href="#landing"><i class="fas fa-angle-down"></i></a> 32 </div> 33</header>
scss
1#app { 2 text-align: center; 3 @include center-wrapp; 4 header { 5 width: 100%; 6 height: 100vh; 7 font-family: 'Orbitron', sans-serif; 8 color: #ffffff; 9 text-shadow: 1px 2px 3px #1c1c1c; 10 background: linear-gradient(135deg, rgba(71, 183, 204, 0.6),rgba(10, 19, 255, 0.6)),url("../img/header-image.jpg"); 11 background-size: cover; 12 @include center-wrapp; 13 .header-navi { 14 position: fixed; 15 z-index: 999; 16 top: 0; 17 width: 100%; 18 height: 60px; 19 background-color: rgba(25, 25, 25, 0.8); 20 display: flex; 21 justify-content: center; 22 img { 23 border-radius: 50%; 24 margin-right: 200px; 25 width: 60px; 26 height: 60px; 27 } 28 nav { 29 ul { 30 margin: 0 auto; 31 display: flex; 32 } 33 li { 34 width: 200px; 35 line-height: 60px; 36 font-size: 20px; 37 font-weight: bold; 38 &:hover { 39 background-color: #ffffff; 40 transition: 0.8s; 41 } 42 } 43 a { 44 @include button-sizing; 45 color: white; 46 &:hover { 47 color: black; 48 transition: 0.7s; 49 } 50 } 51 } //nav 52 } //.header-navi 53 54 .menu-button { 55 cursor: pointer; 56 } 57 .menu { 58 width: 100%; 59 background-color: red; 60 height: 120px; 61 overflow: hidden; 62 } 63 64 #pseudo-element { 65 margin-bottom: 200px; 66 } 67 h1 { 68 margin-bottom: 80px; 69 font-size: 85px; 70 letter-spacing: 0.2em; 71 } 72 h2 { 73 margin-bottom: 150px; 74 font-size: 50px; 75 letter-spacing: 0.3em; 76 } 77 p { 78 font-size: 20px; 79 margin-bottom: 80px; 80 cursor: pointer; 81 &:hover { 82 animation: shake .1s infinite; 83 } 84 } 85 .down-button { 86 width: 40px; 87 height: 40px; 88 border-radius: 50%; 89 border: 1px solid white; 90 &:hover { 91 background-color: white; 92 color: rgba(9, 63, 209, 0.9); 93 transform: scale(0.8); 94 transition: 0.8s; 95 } 96 a { 97 @include button-sizing; 98 } 99 i { 100 height:40px; 101 width: 40px; 102 color: white; 103 font-size: 30px; 104 line-height: 40px; 105 text-shadow: none; 106 &:hover { 107 color: rgb(9, 63, 209); 108 } 109 } 110 } 111 } //header
JavaScript
1Vue.use(window["vue-js-modal"].default); //vue-js-modalの読み込み 2 3const vm = new Vue({ 4 el: '#app', 5 data: { 6 showMenu: false 7 }, 8 methods: { 9 toggleMenu: function () { 10 this.showMenu = !this.showMenu 11 }, 12 show1 : function() { 13 this.$modal.show('html'); 14 }, 15 show2 : function () { 16 this.$modal.show('css'); 17 }, 18 show3 : function () { 19 this.$modal.show('javascript'); 20 }, 21 show4 : function () { 22 this.$modal.show('vue.js'); 23 }, 24 show5 : function () { 25 this.$modal.show('sass'); 26 }, 27 show6 : function () { 28 this.$modal.show('firebase'); 29 }, 30 }, 31})
回答1件
あなたの回答
tips
プレビュー