取公共的APIURL
项目新增common目录,里面有个common.js
const common = { get apiurl(){ var apiurl = uni.getStorageSync("apiurl"); if(apiurl==undefined || apiurl == ''){ apiurl = "http://product.niunan.net"; uni.setStorageSync("apiurl",apiurl); } return apiurl; } } export default common
使用:
<script> import common from "@/common/common.js" export default { data() { return { keyword: '', }; }, onLoad() { var apiurl = common.apiurl; console.log("apiurl:"+apiurl); }, methods: { setset(){ console.log("setsetset"); } } }; </script>
标签:return,log,APIURL,export,common,公共,apiurl From: https://www.cnblogs.com/niunan/p/17470471.html