1

我的快应用打开时,白屏显示了一会儿,然后才出现应用内内容。这些按钮还需要一段时间来响应点击事件。下面是使用的代码:

<template>
  <!-- Only one root node is allowed in template. -->
  <div class="container">
    <input type="button" value=" generate" onclick="write" />
    <input type="button" value="delete" onclick="remove" />
  </div>
</template>

<style>
  .container {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: red;
  }
</style>

<script>
  import file from '@system.file'
  import prompt from '@system.prompt';
  module.exports = {
    data: {
      componentData: {},
      arr: [],
      file: '',
      fileuri: '',
    },
    onInit() {
    },
    onReady() {
      this.write()
    },
    write() {
      console.log("handling success 11222111");
      for (let i = 0; i < 10000; i++) {
        file.writeText({
          uri: 'internal://cache/test/test' + i + '.txt',
          text: 'nihaadpafsafa fsafass faf  sfsa sf',
          encoding: 'UTF-8',
          success: function () {
            console.log('success');
          },
        })
      }
      console.log("handling success 11111");
      prompt.showToast({
        message: '10,000 files written.',
        duration:"2000",
      })
    },
    remove() {
      file.list({
        uri: "internal://cache/test/",
        success: function (data) {
          console.log(data)
          for (let i = 0; i < 1000; i++) {
            console.log("message", data.fileList[i].uri);
            file.delete({
              uri: data.fileList[i].uri,
              success: function (data) {
                console.log("hjj handling success");
              },
              fail: function (data, code) {
                console.log("handling fail, code=" + code + data);
              }
            })
          }
        },
        fail: function (data, code) {
          console.log("handling fail, code=" + code);
        }
      })
      prompt.showToast({
        message: '10,000 files deleted.',
        duration:"2000",
      })
    }
  }
</script>

运行代码时,它显示空白屏幕。请帮我解决这个问题。

请找到所附图片:[![见图片][1]][1][1]:https://i.stack.imgur.com/Xu190.png

4

0 回答 0