diff --git a/packages/password-input/index.js b/packages/password-input/index.js
index 4057fd906..147a498e8 100644
--- a/packages/password-input/index.js
+++ b/packages/password-input/index.js
@@ -2,50 +2,50 @@ import { use } from '../utils';
const [sfc, bem] = use('password-input');
-export default sfc({
- props: {
- info: String,
- errorInfo: String,
- value: {
- type: String,
- default: ''
- },
- length: {
- type: Number,
- default: 6
- }
- },
-
- computed: {
- points() {
- const arr = [];
- for (let i = 0; i < this.length; i++) {
- arr[i] = this.value[i] ? 'visible' : 'hidden';
+export default sfc(
+ {
+ props: {
+ info: String,
+ errorInfo: String,
+ value: {
+ type: String,
+ default: ''
+ },
+ length: {
+ type: Number,
+ default: 6
}
- return arr;
+ },
+
+ render(h, context) {
+ const { props, listeners } = context;
+ const info = props.errorInfo || props.info;
+
+ const Points = [];
+ for (let i = 0; i < props.length; i++) {
+ Points.push(
+
+
+
+ );
+ }
+
+ return (
+
+
{
+ event.stopPropagation();
+ listeners.focus && listeners.focus();
+ }}
+ {...context.data}
+ >
+ {Points}
+
+ {info &&
{info}
}
+
+ );
}
},
-
- render(h) {
- const info = this.errorInfo || this.info;
-
- return (
-
-
{
- event.stopPropagation();
- this.$emit('focus');
- }}
- >
- {this.points.map(visibility => (
- -
-
-
- ))}
-
- {info &&
{info}
}
-
- );
- }
-});
+ true
+);
diff --git a/packages/password-input/test/index.spec.js b/packages/password-input/test/index.spec.js
new file mode 100644
index 000000000..ece87241d
--- /dev/null
+++ b/packages/password-input/test/index.spec.js
@@ -0,0 +1,16 @@
+import PasswordInput from '..';
+import { mount } from '../../../test/utils';
+
+test('focus event', () => {
+ const focus = jest.fn();
+ const wrapper = mount(PasswordInput, {
+ context: {
+ on: {
+ focus
+ }
+ }
+ });
+
+ wrapper.find('.van-password-input__security').trigger('touchstart');
+ expect(focus.mock.calls.length).toEqual(1);
+});