问题描述
我正在使用PHP artisan serve
在远程服务器上启动我的迷你应用程序。
上传后,我停止并重新启动(PHP artisan serve
),但是视图仍然“旧”,有类似缓存的内容,如何清除它?
解决方法
尝试import PropTypes from "prop-types";
import React,{ useContext,useState } from "react";
import { View,Text,TouchableOpacity } from "react-native";
import { LocalizationContext } from "library/localization";
import authenticatedStyle from "../../style";
const SalesRow = (props) => {
const { translations } = useContext(LocalizationContext);
const [displayStats,showHideStats] = useState(false);
const { setupCost,discountRate } = props;
const toggleView = () => {
const state = !displayStats;
showHideStats(state);
};
return (
<>
<View style={authenticatedStyle.SalesRow}>
<View style={authenticatedStyle.size1Children}>
<TouchableOpacity testID="toggle" onPress={toggleView}>
<Text>{translations["Toggle"]}</Text>
</TouchableOpacity>
</View>
</View>
{displayStats && (
<View>
<View style={authenticatedStyle.SalesRow}>
<View style={authenticatedStyle.size1Children}>
<Text>{translations["SetupCost"]}</Text>
<Text>{setupCost}</Text>
</View>
<View style={authenticatedStyle.size1Children}>
<Text>{translations["Discount"]}</Text>
<Text>{discountRate}</Text>
</View>
</View>
</View>
)}
</>
);
};
SalesRow.propTypes = {
discountRate: PropTypes.number.isRequired,setupCost: PropTypes.number.isRequired,};
export default SalesRow;
如果要清除文件缓存,则可以使用clearstatcache()
。如果要在脚本中多次检查文件,请使用clearstatcache()
函数,以避免缓存并获得正确的结果。查看更多here
但是,如果您想清除浏览器缓存,则可以使用标头将其删除。
查看更多here