当前位置:   article > 正文

Harmony实现页面跳转_@media screen and (device-type: tablet) and (orien

@media screen and (device-type: tablet) and (orientation: landscape)

 

页面实现效果

 

datas代码

  1. // common.datas.tabbarItem.js
  2. export default [
  3. {
  4. img:'common/images/home.png',
  5. simg:'common/images/home_s.png',
  6. name:'首页'
  7. },
  8. {
  9. img:'common/images/hot.png',
  10. simg:'common/images/hot_s.png',
  11. name:'热点'
  12. },
  13. {
  14. img:'common/images/us.png',
  15. simg:'common/images/us_s.png',
  16. name:'社区'
  17. },
  18. {
  19. img:'common/images/me.png',
  20. simg:'common/images/me_s.png',
  21. name:'我'
  22. }
  23. ]

child.css代码

  1. .tabbar {
  2. width:360px;
  3. height: 200px;
  4. border: 2px solid #333;
  5. }

child.hml代码

  1. <div class="container">
  2. <div class="box">
  3. <text>我是子组件</text>
  4. <slot></slot>
  5. <slot name="other"></slot>
  6. <button @click="changeFatherNum"> 点击修改</button>
  7. </div>
  8. </div>

child.js代码

  1. //import tabbarItems from '../../common/datas/tabbarItem.js';
  2. export default {
  3. data:{
  4. // tabbarItems
  5. },
  6. changeFatherNum(){
  7. this.$emit("changeFatherNum")
  8. }
  9. }

tabbar.css代码

  1. .tabbar {
  2. position: fixed;
  3. left: 0;
  4. bottom: 0;
  5. }

tabbar.hml代码

  1. <div class="container">
  2. <toolbar class="tabbar">
  3. <toolbar-item for="{{tabbarItems}}"
  4. icon='{{$idx==index?$item.sing: $item.img}}'
  5. value='{{$item.name}}'
  6. onclick="jump($idx)" >
  7. </toolbar-item>
  8. </toolbar>
  9. </div>

tabbar.js代码

  1. import tabbarItems from '../../common/datas/tabbarItem.js';
  2. import router from '@system.router';
  3. export default {
  4. data:{
  5. tabbarItems
  6. },
  7. // props:["index"],
  8. props:{
  9. index:{
  10. type:Number,
  11. default(){
  12. return 0;
  13. }
  14. }
  15. },
  16. jump(index){
  17. /* this.tabbarItems.forEach((item,index) => {
  18. item.img = tabbarItems[index].img;
  19. });
  20. this.tabbarItems[index].img = this.tabbarItems[index].simg;*/
  21. switch(index){
  22. case 0:
  23. router.push({
  24. uri:"pages/index/index",
  25. params:{
  26. info:"这是路由传递的参数"
  27. }
  28. });
  29. break;
  30. case 1:
  31. router.push({
  32. uri:"pages/news/index",
  33. params:{
  34. info:"这是路由传递的参数"
  35. }
  36. });
  37. break;
  38. case 2:
  39. router.push({
  40. uri:"pages/about/index",
  41. params:{
  42. info:"这是路由传递的参数"
  43. }
  44. });
  45. break;
  46. case 3:
  47. router.push({
  48. uri:"pages/me/index",
  49. params:{
  50. info:"这是路由传递的参数"
  51. }
  52. });
  53. break;
  54. }
  55. }
  56. }

about.css代码

  1. .container {
  2. flex-direction: column;
  3. justify-content: center;
  4. align-items: center;
  5. width: 100%;
  6. height: 100%;
  7. }
  8. .title {
  9. font-size: 40px;
  10. color: #000000;
  11. opacity: 0.9;
  12. }
  13. @media screen and (device-type: tablet) and (orientation: landscape) {
  14. .title {
  15. font-size: 100px;
  16. }
  17. }
  18. @media screen and (device-type: wearable) {
  19. .title {
  20. font-size: 28px;
  21. color: #FFFFFF;
  22. }
  23. }
  24. @media screen and (device-type: tv) {
  25. .container {
  26. background-image: url("/common/images/Wallpaper.png");
  27. background-size: cover;
  28. background-repeat: no-repeat;
  29. background-position: center;
  30. }
  31. .title {
  32. font-size: 100px;
  33. color: #FFFFFF;
  34. }
  35. }
  36. @media screen and (device-type: phone) and (orientation: landscape) {
  37. .title {
  38. font-size: 60px;
  39. }
  40. }

about.hml代码

  1. <element name='comp' src='../../components/tabbar/tabbar.hml'></element>
  2. <div class="container">
  3. <text class="title">
  4. 关于我们
  5. </text>
  6. <comp index="2"></comp>
  7. </div>

about.js代码

  1. export default {
  2. data: {
  3. title: ""
  4. },
  5. onInit() {
  6. this.title = this.$t('strings.world');
  7. }
  8. }

index.css代码

  1. .container {
  2. flex-direction: column;
  3. justify-content: center;
  4. align-items: center;
  5. width: 100%;
  6. height: 100%;
  7. }
  8. .title {
  9. font-size: 40px;
  10. color: #000000;
  11. opacity: 0.9;
  12. }
  13. @media screen and (device-type: tablet) and (orientation: landscape) {
  14. .title {
  15. font-size: 100px;
  16. }
  17. }
  18. @media screen and (device-type: wearable) {
  19. .title {
  20. font-size: 28px;
  21. color: #FFFFFF;
  22. }
  23. }
  24. @media screen and (device-type: tv) {
  25. .container {
  26. background-image: url("/common/images/Wallpaper.png");
  27. background-size: cover;
  28. background-repeat: no-repeat;
  29. background-position: center;
  30. }
  31. .title {
  32. font-size: 100px;
  33. color: #FFFFFF;
  34. }
  35. }
  36. @media screen and (device-type: phone) and (orientation: landscape) {
  37. .title {
  38. font-size: 60px;
  39. }
  40. }

index.hml代码

  1. <element name='comp' src='../../components/tabbar/tabbar.hml'></element>
  2. <element src='../../components/child/child.hml'></element>
  3. <div class="container">
  4. <text class="title">
  5. 欢迎来到梦开始的地方
  6. </text>
  7. <text>{{num}}</text>
  8. //自定义
  9. <child @change-father-num="changeNum">
  10. <text>父组件slot内容</text>
  11. <text slot="other">父组件slot-other内容</text>
  12. </child>
  13. <comp index="0"></comp>
  14. </div>

index.js代码

  1. export default {
  2. data: {
  3. title: "",
  4. num:0
  5. },
  6. changeNum(){
  7. this.num++;
  8. }
  9. }

me.css代码

  1. .container {
  2. flex-direction: column;
  3. justify-content: center;
  4. align-items: center;
  5. width: 100%;
  6. height: 100%;
  7. }
  8. .title {
  9. font-size: 40px;
  10. color: #000000;
  11. opacity: 0.9;
  12. }
  13. @media screen and (device-type: tablet) and (orientation: landscape) {
  14. .title {
  15. font-size: 100px;
  16. }
  17. }
  18. @media screen and (device-type: wearable) {
  19. .title {
  20. font-size: 28px;
  21. color: #FFFFFF;
  22. }
  23. }
  24. @media screen and (device-type: tv) {
  25. .container {
  26. background-image: url("/common/images/Wallpaper.png");
  27. background-size: cover;
  28. background-repeat: no-repeat;
  29. background-position: center;
  30. }
  31. .title {
  32. font-size: 100px;
  33. color: #FFFFFF;
  34. }
  35. }
  36. @media screen and (device-type: phone) and (orientation: landscape) {
  37. .title {
  38. font-size: 60px;
  39. }
  40. }

me.hml代码

  1. <element name='comp' src='../../components/tabbar/tabbar.hml'></element>
  2. <div class="container">
  3. <text class="title">
  4. 个人中心
  5. </text>
  6. <comp index="3"></comp>
  7. </div>

me.js代码

  1. export default {
  2. data: {
  3. title: ""
  4. },
  5. onInit() {
  6. this.title = this.$t('strings.world');
  7. }
  8. }

news.css代码

  1. .container {
  2. flex-direction: column;
  3. justify-content: center;
  4. align-items: center;
  5. width: 100%;
  6. height: 100%;
  7. }
  8. .title {
  9. font-size: 40px;
  10. color: #000000;
  11. opacity: 0.9;
  12. }
  13. @media screen and (device-type: tablet) and (orientation: landscape) {
  14. .title {
  15. font-size: 100px;
  16. }
  17. }
  18. @media screen and (device-type: wearable) {
  19. .title {
  20. font-size: 28px;
  21. color: #FFFFFF;
  22. }
  23. }
  24. @media screen and (device-type: tv) {
  25. .container {
  26. background-image: url("/common/images/Wallpaper.png");
  27. background-size: cover;
  28. background-repeat: no-repeat;
  29. background-position: center;
  30. }
  31. .title {
  32. font-size: 100px;
  33. color: #FFFFFF;
  34. }
  35. }
  36. @media screen and (device-type: phone) and (orientation: landscape) {
  37. .title {
  38. font-size: 60px;
  39. }
  40. }

news.hml代码

  1. <element name='comp' src='../../components/tabbar/tabbar.hml'></element>
  2. <div class="container">
  3. <text class="title">
  4. 新闻中心
  5. </text>
  6. <comp index="1"></comp>
  7. </div>

news.js代码

  1. export default {
  2. data: {
  3. title: ""
  4. },
  5. onInit() {
  6. this.title = this.$t('strings.world');
  7. }
  8. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/335169
推荐阅读
相关标签
  

闽ICP备14008679号