Vue.js勉強中 開発環境cloud9です。
掲題の通り、CDNでVue.jsを用いた実装をしていましたが、
別のプロジェクトと誤ってnpm run devをしてしまいました…(大後悔です…)
その際のエラーが以下です。
npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /home/ec2-user/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/home/ec2-user/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: npm ERR! /home/ec2-user/.npm/_logs/2021-10-20T00_30_41_418Z-debug.log
その後、ページにアクセスしても、CSDでVueを使用していますがVueが反映されません…
npm run devする前は{{ g_account }}部分に想定通り表示されておりました。
該当のページにスクリプト部分は以下です。(一部略)
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"></script> <script> new Vue({ el: '#app', data: { form_data: '', errors: [], client_id: '<?php h($client_id); ?>', email: '<?php h($client["email"]); ?>', g_account: '<?php h($client["g_account"]); ?>', mail_from: '<?php h($client["mail_from"]); ?>', gana_fullcode: '<?php print($client["gana_fullcode"]); ?>', new_ganafullcode: '', }, computed: { getImage: function() { if(this.imgname_entry == "") { return ""; } else { let image_url = "../../preview/img/" + this.imgname_entry; return image_url; } }, }, methods: { selectedImage: function(e) { e.preventDefault(); //this.new_image = e.target.files[0]; this.new_image = this.$refs.image.files[0]; console.log("selectedImageメソッド" + this.new_image); }, regist: function() { //入力フォームのバリデーション this.errors = []; if(this.email == '') { //空判定 this.errors.push("Emailを入力してください"); } else { if(!this.email.match(/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/)) { this.errors.push("正しいEmailを入力してください"); } if(this.email.length > 100) { this.errors.push("正しいEmailを入力してください"); } } if(this.g_account == '') { //空判定 this.errors.push("googleアカウントを入力してください"); } if(this.mail_from == '') { //空判定 this.errors.push("送信元アドレスを入力してください"); } else { if(!this.mail_from.match(/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/)) { this.errors.push("正しい送信元アドレスを入力してください"); } if(this.mail_from.length > 100) { this.errors.push("正しい送信元アドレスを入力してください"); } } //errorが0の場合は登録 if(this.errors.length == 0) { this.form_data = new FormData(document.getElementById('form_data')).get(0); console.log(this.form_data); const url = './edit_done.php'; let params = new FormData(); params.append('client_id', this.client_id); params.append('email', this.email); params.append('g_account', this.g_account); params.append('mail_from', this.mail_from); axios.post(url, params, { headers: { 'content-type': 'multipart/form-data' }, }).then(response => { console.log(response.data); if(response.data == 1) { alert("更新しました"); location.href= './detail.php?cid=' + this.client_id; } else { alert("更新に失敗しました:" + response.data); } }); } } } }); </script> </body> </html>
以前と同じようにCDNでVue.jsを使用したいのですが、どうすればよいか、アドバイスいただけますと幸いです。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー