ionic 按钮实现

<html ng-app="ionicApp">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
        <title>菜鸟教程(runoob.com)</title>
        <link href="https://cdn.bootcss.com/ionic/1.3.2/css/ionic.css" rel="stylesheet">
        <script src="https://cdn.bootcss.com/ionic/1.3.2/js/ionic.bundle.min.js"></script>
    </head>
    <body>
    
    <div class="bar bar-header">
      <div class="h1 title" style="background-color: royalblue;">八维商城</div>
    </div>
    
    <div class="content has-header padding scroll scroll-content" style="overflow-y:auto">


      <p><button class="button button-light">button-light</button>
     <button class="button button-stable">button-stable</button>
      </p><p><button class="button button-positive">button-positive</button>
     <button class="button button-calm">button-calm</button>
      </p><p><button class="button button-energized">button-energized</button>
<button class="button button-assertive">button-assertive</button>
      </p><p><button class="button button-royal">button-royal</button>
<button class="button button-dark">button-dark</button></p>


    </div>


<div class="bar bar-footer">
      <div class="h1 title" style="background-color: red;">本商城由八维公司负责维护</div>
    </div>
  </body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ionic中,你可以使用`File`插件来处理文件操作。要复制文件并将其保存到新目录,可以按照以下步骤进行操作: 1. 导入`File`插件 在你的Ionic项目中,运行以下命令来安装`File`插件: ``` ionic cordova plugin add cordova-plugin-file npm install @ionic-native/file ``` 在需要使用`File`插件的组件中导入它: ``` import { File } from '@ionic-native/file/ngx'; ``` 2. 复制文件到新目录 使用`File`插件的`copyFile()`方法来复制文件。该方法需要四个参数: - 原始文件路径 - 原始文件名 - 目标目录路径 - 目标文件名 以下是一个示例代码,可以将`/src/assets/file.txt`文件复制到`/src/assets/copy`目录中的`copy.txt`文件中: ``` import { File } from '@ionic-native/file/ngx'; constructor(private file: File) {} // 复制文件到新目录 copyFile() { const sourceFilePath = this.file.applicationDirectory + 'www/assets/file.txt'; const sourceFileName = 'file.txt'; const targetDirPath = this.file.applicationDirectory + 'www/assets/copy'; const targetFileName = 'copy.txt'; this.file.checkDir(this.file.applicationDirectory, 'www/assets/copy') .then(() => { console.log('目录已存在'); this.file.copyFile(sourceFilePath, sourceFileName, targetDirPath, targetFileName) .then(() => console.log('文件已复制')) .catch(err => console.log('文件复制失败:', err)); }) .catch(() => { console.log('目录不存在'); this.file.createDir(this.file.applicationDirectory + 'www/assets', 'copy', false) .then(() => { console.log('目录已创建'); this.file.copyFile(sourceFilePath, sourceFileName, targetDirPath, targetFileName) .then(() => console.log('文件已复制')) .catch(err => console.log('文件复制失败:', err)); }) .catch(err => console.log('目录创建失败:', err)); }); } ``` 在上面的示例代码中,我们首先检查目标目录是否已存在,如果目录存在,则直接复制文件。如果目录不存在,则先创建目录,然后再复制文件。 注意,在使用`File`插件时,需要在`config.xml`文件中添加以下配置: ``` <platform name="android"> <allow-intent href="market:*" /> <allow-intent href="geo:*" /> <allow-intent href="mailto:*" /> <allow-intent href="sms:*" /> <allow-intent href="tel:*" /> <allow-intent href="http:*" /> <allow-intent href="https:*" /> <allow-intent href="cdvfile:*" /> </platform> ``` 这样就可以实现Ionic中复制文件并保存到新目录了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值