env.uvue 1.2 KB
Newer Older
M
mahaifeng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<template>
  <!-- #ifdef APP -->
  <text>操作日志</text><button size="mini" @click="log=''">清空日志</button>
  <text style="margin: 2px; padding: 2px; border: 1px solid #000000;">{{ log }}</text>
  <scroll-view style="flex: 1;">
  <!-- #endif -->
    <!-- #ifdef APP -->
    <button class="btnstyle" type="primary" @tap="geAbsPath(sandboxPath)" id="btn-path">应用外置沙盒目录uni.env.SANDBOX_PATH</button>
    <button class="btnstyle" type="primary" @tap="geAbsPath(cachePath)" id="btn-path">缓存文件目录uni.env.CACHE_PATH</button>
    <button class="btnstyle" type="primary" @tap="geAbsPath(userPath)" id="btn-path">用户文件目录uni.env.USER_DATA_PATH</button>
    <!-- #endif -->
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>

<script>
  export default {

    data() {
      return {
        log: "",
        userPath: uni.env.USER_DATA_PATH,
        sandboxPath: uni.env.SANDBOX_PATH,
        cachePath: uni.env.CACHE_PATH,
      }
    },
    onLoad() {
    },

    methods: {
      geAbsPath(path ?: Any) {
M
mahaifeng 已提交
33 34 35 36
        // #ifdef APP-ANDROID
          this.log += UTSAndroid.convert2AbsFullPath(path as String) + '\n'
        // #endif

M
mahaifeng 已提交
37 38 39 40 41 42 43 44 45 46
      }
    }
  }
</script>

<style>
  .btnstyle {
    margin: 4px;
  }
</style>