index.js 872 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * FeHelper 进制转换工具
  3. */
  4. new Vue({
  5. el: '#containerRadix',
  6. data: {
  7. fromArray: [2, 4, 8, 10, 16],
  8. fromSelected: 10,
  9. toArray: [2, 4, 8, 10, 16],
  10. toSelected: 16,
  11. srcValue: 100,
  12. rstValue: 0
  13. },
  14. mounted: function () {
  15. // 进制转换的初始化
  16. this.radixConvert();
  17. },
  18. methods: {
  19. getId: (type, id) => [type, id].join('_'),
  20. radixRadioClicked: function (type, n) {
  21. if (type === 1) {
  22. this.fromSelected = n;
  23. } else {
  24. this.toSelected = n;
  25. }
  26. this.radixConvert();
  27. },
  28. radixConvert: function () {
  29. this.$nextTick(() => {
  30. this.rstValue = parseInt(this.srcValue, this.fromSelected).toString(this.toSelected);
  31. });
  32. }
  33. }
  34. });