env.uvue 1.5 KB
Newer Older
M
mahaifeng 已提交
1 2 3 4 5 6 7 8 9 10
<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>
M
mahaifeng 已提交
11 12
    <button class="btnstyle" type="primary" @tap="geAbsPath(internalSandboxPath)"
      id="btn-path">应用内置沙盒目录uni.env.ANDROID_INTERNAL_SANDBOX_PATH</button>
M
mahaifeng 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    <!-- #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,
M
mahaifeng 已提交
28
        internalSandboxPath: uni.env.ANDROID_INTERNAL_SANDBOX_PATH,
M
mahaifeng 已提交
29 30 31 32 33 34
      }
    },
    onLoad() {
    },

    methods: {
M
mahaifeng 已提交
35
      geAbsPath(path ?: any) {
M
mahaifeng 已提交
36
        // #ifdef APP-ANDROID
M
mahaifeng 已提交
37
          this.log += UTSAndroid.convert2AbsFullPath(path as string) + '\n'
M
mahaifeng 已提交
38 39
        // #endif

M
mahaifeng 已提交
40 41 42 43 44 45 46 47 48 49
      }
    }
  }
</script>

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