HarmonyOS DocumentViewPicker有没有完整的示例

DocumentViewPicker有没有完整的示例,没看明白源文件如何设置。

HarmonyOS
2024-08-04 14:20:03
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
sslijun

请参考:

async function example07() { 
  try { 
    let DocumentSelectOptions = new picker.DocumentSelectOptions(); 
    let documentPicker = new picker.DocumentViewPicker(); 
    documentPicker.select(DocumentSelectOptions).then((DocumentSelectResult: Array<string>) => { 
      console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult)); 
    }).catch((err: BusinessError) => { 
      console.error('DocumentViewPicker.select failed with err: ' + JSON.stringify(err)); 
    }); 
  } catch (error) { 
    let err: BusinessError = error as BusinessError; 
    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err)); 
  } 
} 
 
 
async function example08() { 
  try { 
    let DocumentSelectOptions = new picker.DocumentSelectOptions(); 
    let documentPicker = new picker.DocumentViewPicker(); 
    documentPicker.select(DocumentSelectOptions, (err: BusinessError, DocumentSelectResult: Array<string>) => { 
      if (err) { 
        console.error('DocumentViewPicker.select failed with err: ' + JSON.stringify(err)); 
        return; 
      } 
      console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult)); 
    }); 
  } catch (error) { 
    let err: BusinessError = error as BusinessError; 
    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err)); 
  } 
} 
 
async function example09() { 
  try { 
    let documentPicker = new picker.DocumentViewPicker(); 
    documentPicker.select((err: BusinessError, DocumentSelectResult: Array<string>) => { 
      if (err) { 
        console.error('DocumentViewPicker.select failed with err: ' + JSON.stringify(err)); 
        return; 
      } 
      console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult)); 
    }); 
  } catch (error) { 
    let err: BusinessError = error as BusinessError; 
    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err)); 
  } 
} 
 
async function example10() { 
  try { 
    let DocumentSaveOptions = new picker.DocumentSaveOptions(); 
    DocumentSaveOptions.newFileNames = ['DocumentViewPicker01.txt']; 
    let documentPicker = new picker.DocumentViewPicker(); 
    documentPicker.save(DocumentSaveOptions).then((DocumentSaveResult: Array<string>) => { 
      console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult)); 
    }).catch((err: BusinessError) => { 
      console.error('DocumentViewPicker.save failed with err: ' + JSON.stringify(err)); 
    }); 
  } catch (error) { 
    let err: BusinessError = error as BusinessError; 
    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err)); 
  } 
} 
 
 
async function example11() { 
  try { 
    let DocumentSaveOptions = new picker.DocumentSaveOptions(); 
    DocumentSaveOptions.newFileNames = ['DocumentViewPicker02.txt']; 
    let documentPicker = new picker.DocumentViewPicker(); 
    documentPicker.save(DocumentSaveOptions, (err: BusinessError, DocumentSaveResult: Array<string>) => { 
      if (err) { 
        console.error('DocumentViewPicker.save failed with err: ' + JSON.stringify(err)); 
        return; 
      } 
      console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult)); 
    }); 
  } catch (error) { 
    let err: BusinessError = error as BusinessError; 
    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err)); 
  } 
} 
 
async function example12() { 
  try { 
    let documentPicker = new picker.DocumentViewPicker(); 
    documentPicker.save((err: BusinessError, DocumentSaveResult: Array<string>) => { 
      if (err) { 
        console.error('DocumentViewPicker.save failed with err: ' + JSON.stringify(err)); 
        return; 
      } 
      console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult)); 
    }); 
  } catch (error) { 
    let err: BusinessError = error as BusinessError; 
    console.error('DocumentViewPicke')
分享
微博
QQ
微信
回复
2024-08-05 12:00:57
相关问题
有没有示例?
246浏览 • 1回复 待解决
HarmonyOS 有没有图片取色API ?
205浏览 • 1回复 待解决
HarmonyOS 有没有密码控件?
344浏览 • 1回复 待解决
HarmonyOS 有没有类似scrollview组件
315浏览 • 1回复 待解决
HarmonyOS 有没有单指旋转api?
173浏览 • 0回复 待解决
HarmonyOS 有没有活体检测SDK?
190浏览 • 1回复 待解决