Commit f7c8bfe1 by lirandong

添加 taro-native-shell

parent e8435962
/taro-native-shell
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }], "no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }] "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
}, },
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
"jsx": true "jsx": true
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
"useJSXTextNode": true, "useJSXTextNode": true,
"project": "./tsconfig.json" "project": "./tsconfig.json"
} }
} }
{
"editor.formatOnSave": true,
"prettier.stylelintIntegration": true,
"prettier.tabWidth": 2,
"prettier.singleQuote": true,
"typescript.tsdk": "node_modules/typescript/lib",
"prettier.printWidth": 120,
"prettier.semi": false
}
{ {
"name": "Vmatrix-client-taro", "name": "vmatrix-client-taro",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"description": "", "description": "",
...@@ -36,35 +36,35 @@ ...@@ -36,35 +36,35 @@
"@tarojs/taro-swan": "1.3.12", "@tarojs/taro-swan": "1.3.12",
"@tarojs/taro-tt": "1.3.12", "@tarojs/taro-tt": "1.3.12",
"@tarojs/taro-weapp": "1.3.12", "@tarojs/taro-weapp": "1.3.12",
"nervjs": "^1.4.0",
"nerv-devtools": "^1.4.0", "nerv-devtools": "^1.4.0",
"nervjs": "^1.4.0",
"redux": "^4.0.0", "redux": "^4.0.0",
"redux-logger": "^3.0.6", "redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0" "redux-thunk": "^2.3.0"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"@tarojs/plugin-babel": "1.3.12", "@tarojs/plugin-babel": "1.3.12",
"@tarojs/plugin-csso": "1.3.12", "@tarojs/plugin-csso": "1.3.12",
"@tarojs/plugin-less": "1.3.12", "@tarojs/plugin-less": "1.3.12",
"@tarojs/plugin-uglifyjs": "1.3.12", "@tarojs/plugin-uglifyjs": "1.3.12",
"@tarojs/webpack-runner": "1.3.12", "@tarojs/webpack-runner": "1.3.12",
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/parser": "^1.6.0",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5", "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"babel-eslint": "^8.2.3",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"eslint-config-taro": "1.3.12", "eslint-config-taro": "1.3.12",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.3.12",
"stylelint": "9.3.0", "stylelint": "9.3.0",
"stylelint-config-taro-rn": "1.3.12", "stylelint-config-taro-rn": "1.3.12",
"stylelint-taro-rn": "1.3.12", "stylelint-taro-rn": "1.3.12",
"eslint-plugin-taro": "1.3.12",
"@typescript-eslint/parser": "^1.6.0",
"typescript": "^3.0.1" "typescript": "^3.0.1"
} }
} }
...@@ -36,53 +36,65 @@ type PageState = {} ...@@ -36,53 +36,65 @@ type PageState = {}
type IProps = PageStateProps & PageDispatchProps & PageOwnProps type IProps = PageStateProps & PageDispatchProps & PageOwnProps
interface Index { interface Index {
props: IProps; props: IProps
} }
@connect(({ counter }) => ({ @connect(
counter ({ counter }) => ({
}), (dispatch) => ({ counter
add () { }),
dispatch(add()) dispatch => ({
}, add() {
dec () { dispatch(add())
dispatch(minus()) },
}, dec() {
asyncAdd () { dispatch(minus())
dispatch(asyncAdd()) },
} asyncAdd() {
})) dispatch(asyncAdd())
}
})
)
class Index extends Component { class Index extends Component {
/**
/**
* 指定config的类型声明为: Taro.Config * 指定config的类型声明为: Taro.Config
* *
* 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型 * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
* 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
* 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型 * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
*/ */
config: Config = { config: Config = {
navigationBarTitleText: '首页' navigationBarTitleText: '首页'
} }
componentWillReceiveProps (nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
} }
componentWillUnmount () { } componentWillUnmount() {}
componentDidShow () { } componentDidShow() {}
componentDidHide () { } componentDidHide() {}
render () { render() {
return ( return (
<View className='index'> <View className="index">
<Button className='add_btn' onClick={this.props.add}>+</Button> <Button className="add_btn" onClick={this.props.add}>
<Button className='dec_btn' onClick={this.props.dec}>-</Button> +
<Button className='dec_btn' onClick={this.props.asyncAdd}>async</Button> </Button>
<View><Text>{this.props.counter.num}</Text></View> <Button className="dec_btn" onClick={this.props.dec}>
<View><Text>Hello, World</Text></View> -
</Button>
<Button className="dec_btn" onClick={this.props.asyncAdd}>
async
</Button>
<View>
<Text>{this.props.counter.num}</Text>
</View>
<View>
<Text>Hello, World</Text>
</View>
</View> </View>
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment