laravelでVueを試しています。
「main.blade.html」が全ファイル共通のテンプレートです。
「<div id="app">」をvueでマウントしています。
Vueで特定のページでしか使わないコンポーネントや処理に関して疑問が2点あります。
- 特定のページでしか使わないcomponentであったとしても、
componentが増えるごとに「app.js」にcomponentを追記していけばいいのか? - componentを作るほどでなく、特定のページでしか利用しない
ワンポイントの操作は、どのように扱えばいいのか。
「app.js」のnew Vue内にdataやmethodsを随時記述するのか。
お答え頂けると助かります。
main.blade.html
html
1<!DOCTYPE html> 2<html lang="ja"> 3 4<head> 5 <meta charset="UTF-8"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 8 <meta name="csrf-token" content="{{ csrf_token() }}"> 9 <title>@yield('title')|メインタイトル</title> 10 @include("layout.styles") 11 <style type="text/css"> 12 </style> 13</head> 14 15<body> 16 <div id="app"> 17 @yield('content') 18 </div> 19 <script src="{{ mix('js/app.js') }}"></script> 20</body> 21 22</html>
resources/js/app.js
javascript
1require('./bootstrap'); 2 3window.Vue = require('vue'); 4 5Vue.component('vote-component', require('./components/VoteComponent.vue').default); 6 7const app = new Vue({ 8 el: '#app' 9});
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/22 06:35