LaravelでReactを導入したいのですがうまく表示されません。どのようにすればいいのでしょうか?
ちなみに一度表示はされたのですが、その後少し回収して表示されなくなってしまったので元に戻しても表示されなくなってしまいました。
反応までに時間がかかるのでしょうか?
以下参考のコードになります
Laravel バーション5.5
welcom.blade.php
1<!DOCTYPE html> 2<html> 3 <head> 4 <meta charset="utf-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <meta name="viewport" content="width=device-width, initial-scale=1"> 7 <meta name="csrf-token" content="{{ csrf_token() }}"> 8 <title>Laravel React Example</title> 9 <link href="{{mix('/css/app.css')}}" rel="stylesheet" type="text/css"> 10 </head> 11 <body> 12 <div id="example"></div> 13 <script src="{{mix('/js/app.js')}}" ></script> 14 </body> 15</html>
appjs
1 2/** 3 * First we will load all of this project's JavaScript dependencies which 4 * includes React and other helpers. It's a great starting point while 5 * building robust, powerful web applications using React + Laravel. 6 */ 7 8require('./bootstrap'); 9 10/** 11 * Next, we will create a fresh React component instance and attach it to 12 * the page. Then, you may begin adding components to this application 13 * or customize the JavaScript scaffolding to fit your unique needs. 14 */ 15 16require('./components/Example');
Example.js
js
1import React, { Component } from 'react'; 2 3export default class Example extends Component { 4 render() { 5 return ( 6 <div className="container"> 7 <div className="row"> 8 <div className="col-md-8 col-md-offset-2"> 9 <div className="panel panel-default"> 10 <div className="panel-heading">Example Component</div> 11 12 <div className="panel-body"> 13 I am an example component! 14 </div> 15 </div> 16 </div> 17 </div> 18 </div> 19 ); 20 } 21}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。