2022-05-05 16:41:22
0
一.创建项目
二.代码示例
Index.hml
- <div class="container">
- <text class="txt" onclick="goSearched"><span>{{title}}</span> </text>
- </div>
复制代码Index.css
- .container {
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: 100%;
- height: 100%;
- }
- .txt {
- font-size: 24px;
- }
复制代码
Index.js
- import router from '@system.router';
- import file from '@system.file';
- import window from '@ohos.window';
- export default {
- data: {
- title: "点击去下一页"
- },
- goSearched(){
- router.push({
- uri:"pages/searched/searched"
- })
- }
- }
复制代码
Searched.hml
- <div class="container">
- <search hint="请输入搜索内容" value="" searchbutton="搜索" onchange="change" @search="search" onsubmit="submit">
- </search>
- </div>
复制代码
Searched.js
- import router from '@system.router';
- import prompt from '@system.prompt';
- export default {
- data: {
- content: ''
- },
- change(e){
- this.content = e.text
- console.log("搜索值:" + this.content)
- },
- submit(){
- if (this.content == "") {
- prompt.showToast({
- message:"您搜索的内容为空"
- })
- }else{
- router.push({
- uri:'pages/index/index',
- params:{
- title:"这里是您搜索的内容页"
- }
- })
- }
- }
- }
复制代码
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容图片侵权或者其他问题,请联系本站作侵删。
侵权投诉