December 2016
Beginner to intermediate
334 pages
6h 25m
English
Enhance our MathPlugin with trigonometrical functions (sine, cosine, and tangent).
Actually, it is just about adding the missing directives and using the Math object's functions in it. Open VueMathPlugin.js and add the following:
//VueMathPlugin.js
export default {
install: function (Vue) {
Vue.directive('square', function (el, binding) {
el.innerHTML = Math.pow(binding.value, 2);
});
Vue.directive('sqrt', function (el, binding) {
el.innerHTML = Math.sqrt(binding.value);
});
Vue.directive('sin', function (el, binding) { el.innerHTML = Math.sin(binding.value); }); Vue.directive('cos', function (el, binding) { el.innerHTML = Math.cos(binding.value); ...Read now
Unlock full access