Filter input text only accept number and dot vue.js

Source : Mengseng Oeng (2018), https://stackoverflow.com/questions/39782176/filter-input-text-only-accept-number-and-dot-vue-js

HTML

 <input @keypress="onlyNumber" type="text">

VUE JS

onlyNumber ($event) {
   //console.log($event.keyCode); //keyCodes value
   let keyCode = ($event.keyCode ? $event.keyCode : $event.which);
   if ((keyCode < 48 || keyCode > 57) && keyCode !== 46) { // 46 is dot
      $event.preventDefault();
   }
}

Fixed jscolor.js not work with Vue updated by AJAX color value

For example:

We got some data form AJAX and the valuable is “topBGColor”.

in HTML

<input data-jscolor="">

add ref="topBGColor"

<input data-jscolor="" ref="topBGColor">

in Javascript (After get ajax value)

let topBGColor = "#ff0000";

this.$refs.topBGColor.style = 'background-image: linear-gradient(to right, '+topBGColor+' 0%, '+topBGColor+' 30px, rgba(0, 0, 0, 0) 31px, rgba(0, 0, 0, 0) 100%) !important; background-position: left top, left top !important; background-size: auto, 32px 16px !important; background-repeat: repeat-y, repeat-y !important; background-origin: padding-box, padding-box !important; padding-left: 40px !important;';

js read the URL parameters

edit test.html
<div id="test"></div>

<script>
  const p = new URLSearchParams(window.location.search);
  if (p.has('y')) {
    year = parseInt(p.get('y'), 10);
    document.getElementById("test").innerHTML = year;
  }
</script>

test.html?y=1000

result:
1000