changeSize.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <page-meta :root-font-size="getRootFontSize()"></page-meta>
  3. <view>
  4. <view class="uni-padding-wrap uni-common-mt" style="margin-top: 50upx;">
  5. <view class="titleBox">
  6. <view style="font-size:25upx">A</view>
  7. <view style="font-size:30upx">标准</view>
  8. <view style="font-size:35upx">A</view>
  9. <view style="font-size:40upx">A</view>
  10. </view>
  11. <view>
  12. <slider min="10" max="16" :value="fontValue" @change="sliderChange" show-value step="2"/>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import base from '../../utils/base.js';
  19. export default {
  20. extends: base,
  21. data() {
  22. return {
  23. fontValue:12,
  24. rootFontSize:'12upx',
  25. fontStart:uni.getStorageSync('root_font_size') + '',
  26. fontEnd:uni.getStorageSync('root_font_size') + ''
  27. }
  28. },
  29. onLoad() {
  30. const self = this;
  31. //当前字体大小
  32. self.fontValue = parseInt(self.getRootFontSize().split('px')[0]);
  33. console.log(self.fontValue )
  34. },
  35. methods: {
  36. sliderChange(e) {
  37. console.log('value 发生变化:' + e.detail.value)
  38. const self = this;
  39. let nowFontSize = e.detail.value + 'px';
  40. console.log(nowFontSize)
  41. self.fontEnd = nowFontSize;
  42. console.log(nowFontSize)
  43. self.setRootFontSize(nowFontSize);
  44. },
  45. //这里设置一个事件,使用uni.reLaunch跳转到某个页面,并关闭所有页面
  46. /*onNavigationBarButtonTap() {
  47. uni.reLaunch({
  48. url:"../tabbar-4"
  49. })
  50. }*/
  51. }
  52. }
  53. </script>
  54. <style>
  55. .titleBox{
  56. width: 80%;
  57. display: flex;
  58. align-items: center;
  59. justify-content: space-between;
  60. margin: 30upx 0;
  61. margin-left: 5%;
  62. }
  63. </style>