File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 88 ref =" numeric"
99 type =" tel"
1010 v-model =" amount"
11+ v-if =" !readOnly"
1112 >
13+ <span v-else ref =" readOnly" > {{ amount }} </span >
1214</template >
1315
1416<script >
@@ -86,6 +88,24 @@ export default {
8688 value: {
8789 required: true ,
8890 type: [Number , String ]
91+ },
92+
93+ /**
94+ * Hide input and show value in text only.
95+ */
96+ readOnly: {
97+ default: false ,
98+ required: false ,
99+ type: Boolean
100+ },
101+
102+ /**
103+ * Class for the span tag when readOnly props is true.
104+ */
105+ readOnlyClass: {
106+ default: ' ' ,
107+ required: false ,
108+ type: String
89109 }
90110 },
91111
@@ -257,6 +277,7 @@ export default {
257277 watch: {
258278 /**
259279 * Watch for value change from other input.
280+ *
260281 * @param {Number} val
261282 * @param {Number} oldVal
262283 */
@@ -267,6 +288,20 @@ export default {
267288 this .formatValue (val)
268289 }
269290 }
291+ },
292+
293+ /**
294+ * When readOnly is true, replace the span tag class.
295+ *
296+ * @param {Number} val
297+ * @param {Number} oldVal
298+ */
299+ readOnly (val , oldVal ) {
300+ if (oldVal === false && val === true ) {
301+ this .$nextTick (() => {
302+ this .$refs .readOnly .className = this .readOnlyClass
303+ })
304+ }
270305 }
271306 },
272307
You can’t perform that action at this time.
0 commit comments