我通过从github存储库创建管道将我的react项目部署到heroku服务器。
react项目由import 'package:flutter/material.dart';
import 'model/continent_model.dart';
import 'services/continent_services.dart';
class ContinentPage2 extends StatefulWidget {
ContinentPage2() : super();
@override
_ContinentPageState createState() => _ContinentPageState();
}
class _ContinentPageState extends State<ContinentPage2> {
List<Continent> _continent;
@override
void initState() {
super.initState();
ContinentServices.getContinent().then((continents) {
setState(() {
_continent = continents;
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('')),
body: ListView.separated(
separatorBuilder: (BuildContext context, int index) {
return SizedBox(height: 10);
},
shrinkWrap: true,
itemCount: null == _continent ? 0 : _continent.length,
itemBuilder: (context, index) {
return Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[
Row(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: <Widget>[
Expanded(flex: 1, child: Text(_continent[index].continent)),
Expanded(
flex: 2,
child: Container(
height: 50,
child: ListView.separated(
separatorBuilder: (BuildContext context, int index) {
return SizedBox(width: 10);
},
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: null == _continent ? 0 : _continent[index].country.length,
itemBuilder: (context, countryIndex) {
print(_continent[index].country[countryIndex].name);
return Row(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[
Container(
width: 100,
child: Column(children: <Widget>[
Text(
_continent[index].country[countryIndex].name,
),
Text(_continent[index].country[countryIndex].capital,
style: TextStyle(
color: Colors.blue,
)),
]))
]);
})))
])
]);
}));
}
}
Procfile
create-react-app
src / index.js
web: node src/index.js
并且我还在import React from 'react'
import ReactDOM from 'react-dom'
import './style.css'
import App from './App'
import * as serviceWorker from './serviceWorker'
import { Provider } from 'react-redux'
import { createStore, applyMiddleware } from 'redux'
import Reducer from './redux'
import thunk from 'redux-thunk'
import { composeWithDevTools } from 'redux-devtools-extension'
import AirlockTheme from './config/theme'
import Pusher from 'pusher-js'
import { setPusherClient } from 'react-pusher'
const store = createStore(Reducer, composeWithDevTools(applyMiddleware(thunk)))
// Puhser
const pusherClient = new Pusher(process.env.REACT_APP_PUSHER_APP_KEY, {
cluster: process.env.REACT_APP_PUSHER_APP_CLUSTER,
})
setPusherClient(pusherClient)
ReactDOM.render(
<Provider store={store}>
<AirlockTheme>
<App />
</AirlockTheme>
</Provider>,
document.getElementById('root'),
)
serviceWorker.unregister()
中添加了"type":"module"
以启用ESMA脚本编译。