MCPcopy Index your code
hub / github.com/keepfool/vue-tutorials / dataAPI

Function dataAPI

06.Router/basic/js/vue.js:8873–9045  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

8871 var filterRE$1 = /[^|]\|[^|]/;
8872
8873 function dataAPI (Vue) {
8874 /**
8875 * Get the value from an expression on this vm.
8876 *
8877 * @param {String} exp
8878 * @param {Boolean} [asStatement]
8879 * @return {*}
8880 */
8881
8882 Vue.prototype.$get = function (exp, asStatement) {
8883 var res = parseExpression(exp);
8884 if (res) {
8885 if (asStatement) {
8886 var self = this;
8887 return function statementHandler() {
8888 self.$arguments = toArray(arguments);
8889 var result = res.get.call(self, self);
8890 self.$arguments = null;
8891 return result;
8892 };
8893 } else {
8894 try {
8895 return res.get.call(this, this);
8896 } catch (e) {}
8897 }
8898 }
8899 };
8900
8901 /**
8902 * Set the value from an expression on this vm.
8903 * The expression must be a valid left-hand
8904 * expression in an assignment.
8905 *
8906 * @param {String} exp
8907 * @param {*} val
8908 */
8909
8910 Vue.prototype.$set = function (exp, val) {
8911 var res = parseExpression(exp, true);
8912 if (res && res.set) {
8913 res.set.call(this, this, val);
8914 }
8915 };
8916
8917 /**
8918 * Delete a property on the VM
8919 *
8920 * @param {String} key
8921 */
8922
8923 Vue.prototype.$delete = function (key) {
8924 del(this._data, key);
8925 };
8926
8927 /**
8928 * Watch an expression, trigger callback when its
8929 * value changes.
8930 *

Callers 1

vue.jsFile · 0.70

Calls 7

parseExpressionFunction · 0.70
toArrayFunction · 0.70
delFunction · 0.70
parseDirectiveFunction · 0.70
parseTextFunction · 0.70
getPathFunction · 0.70
cleanFunction · 0.70

Tested by

no test coverage detected