我已經定義上Color.js一些常量,但有些顏色是不確定的,當我把它在Screen.js出口常數變量反應本土
我用反應母語爲這個項目0.45。下面是我寫的代碼:
Color.js
export const ATHENS_GRAY = '#EDEEF0';
export const AQUA_SPRING = '#F8FBFD';
export const BLACK = '#000000';
export const BRIGHT_TURQUOISE = '#1BC1F1';
export const CATSKILL_WHITE = '#E4ECF4';
export const FROLY = '#F68181';
export const FUN_BLUE = '#1B61AD';
export const HIT_GRAY = '#A3AEB9';
export const JUMBO = '#7C7D80';
export const LIMED_SPRUCE = '#3D474C';
Screen.js
import React, {Component} from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import * as Color from './Color';
export default class Screen extends Component {
constructor(props) {
super(props);
console.log(Color.BRIGHT_TURQUOISE);
console.log(Color.FUN_BLUE);
}
render() {
return (<View/>)
}
}
中的console.log結果:
Color.BRIGHT_TURQUOISE是不確定的
Color.FUN_BLUE是'#1B61AD'
你有什麼想法解決這個問題嗎?
我不認爲沒有錯,也許在YPO? :( – btzr
這就像有一個緩存,因爲當我改變Color.js上的FUN_BLUE變量,就像導出常量FUN_BLUE ='#FFFFFF';值仍然是#1B61AD,我在iOS模擬器上運行我的應用程序,我有按Command + r刷新我的模擬器 – RobbyWH
https://gist.github.com/jarretmoses/c2e4786fd342b3444f3bc6beff32098d – btzr