我很喜歡mobx,並且在某些平板電腦上實現了一個小應用程序,並且遇到了Android WebView上較老的JavaScript問題(由於年齡原因無法升級的平板電腦)。mobx @observable在較舊的Android 4.4平板電腦上拋出錯誤
Android平板:4.4的Nexus(棒棒糖)
的誤差小於,雖然它看起來像在mobx.js文件(以下功能)圍繞2740具有與舊JavaScript引擎@observables問題。
我目前正在使用webpack(見下文)來傳輸我的js。任何與此有關的幫助將非常感謝,因爲我真的想用mobx前進。
此致 克里斯
線2740在mobx.js
function isES6Map (thing) {
if (thing instanceof getGlobal().Map) {
return true;
}
return false;
}
控制檯錯誤:
[mobx],是由一個反應或觀察者拋出釣到未捕獲的異常組件,在:'反應[CustomerFeedback#0.render()] TypeError message: 「預計在instanceof檢查功能,但有位置頁」 堆棧:(...) get stack:function(){[native code]} set stack:function(){[native code]} proto :錯誤 mobx.js:1284 Reaction.reportExceptionInDerivation
的WebPack:
'use strict';
const autoprefixer = require('autoprefixer');
const copyWebpackPlugin = require('copy-webpack-plugin');
const extractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const scssLoaders = [
'css-loader',
'postcss-loader',
'sass-loader?indentedSyntax=false&includePaths[]=' + path.resolve(__dirname, './application')
];
const config = {
debug: true,
devtool: 'source-map',
entry: ['babel-polyfill', './index.js'],
module: {
loaders: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
loader: ['babel-loader'],
query: {
cacheDirectory: true,
plugins: [
'transform-decorators-legacy',
'transform-class-properties',
'mobx-deep-action'
],
presets: ['es2015', 'stage-0', 'react'],
babelrc: false
}
},
{
test: /.scss$/,
loader: extractTextPlugin.extract('style-loader', scssLoaders.join('!'))
},
{
test: /.(svg|jpg|png)$/,
loader: 'file-loader?name=/media/[name].[ext]'
}
]
},
output: {
path: path.join(__dirname, './build'),
publicPath: '/build',
filename: '[name].js'
},
plugins: [
new extractTextPlugin('[name].css')
],
postcss: [
autoprefixer({
browsers: ['last 2 versions']
})
],
resolve: {
extensions: ['', '.js', '.jsx', '.scss'],
modulesDirectories: ['./node_modules/'],
root: [path.join(__dirname, './application')]
}
};
module.exports = config;
APPSTATE文件:
import { action, computed, extendObservable, toJS } from 'mobx';
class CustomerFeedbackState {
constructor() {
// Initializes all observables
this.initializeStoreData();
}
/* ACTIONS */
// Initialize the store's state, allowing a reinitialization of the app as needed (reset to default state)
@action initializeStoreData() {
extendObservable(this, {
// Keeps track of what page the user is on - 'locations-page' is the start page
currentPageName: 'locations-page',
// Keeps track of what question is being asked
currentQuestionNumber: 0,
// Set to true when the JSON data comes back successful
dataFetched: false,
// sets the active state for the next button
disableNextPage: true,
// Keeps track of page history
lastPageVisitedArray: [],
// Current Location Id
locationId: 0,
// Mood link active states
moodLinkHappyIsActive: false,
moodLinkNeutralIsActive: false,
moodLinkSadIsActive: false,
// Next page available
nextPage: '',
// User mood
userMood: ''
});
},
// ...
}
你是否在代碼中使用了'babel-polyfill'? 'import'babel-polyfill';' – Tholle
yes @Tholle,即在webpack.config:entry:['babel-polyfill','./index.js'], – Centinel3
啊,我錯過了。很有意思。可能值得[**創建問題**](https://github.com/mobxjs/mobx/issues/new)? – Tholle