나는 유성 서버 설치의 주어진 예를 시험 중이다.이 예제에서는 모든 것이 좋다. 그러나 하나의 새로운 입력 필드를 추가했다. 사용 방법 자바 스크립트에서이 입력 텍스트 값 사용 유성 템플릿 .I 이것에 대해 아무런 생각이 들지 않으므로 도와주세요.Get HTML HTML을 유성을 사용하여 자바 스크립트에 입력
html로 코드 :
<head>
<title>myapp</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<h1>Hello World!</h1>
{{greeting}} <br>
First name: <input type="text" name="firstname"><br>
<input type="button" value="Click" />
</template>
JS 코드 : 클라이언트 내부
if (Meteor.isClient)
{
Template.hello.greeting = function()
{
return "Welcome to myapp.";
};
Template.hello.events
({
'click input' : function()
{
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
alert("firstName="+ //here get input text value);
}
});
}
if (Meteor.isServer)
{
Meteor.startup(function()
{
// code to run on server at startup
console.log("Is Running Server");
});
}
잘 작동합니다. js 콘솔에서 "단추를 눌렀습니다"라는 메시지가 표시되지 않습니까? –
이것은 나에게 잘 돌아가며 작동하지 않을 이유가 없습니다. –
그래,하지만 나 한테는 효과가 없어. 내가 할 수있는 실수는 뭐야? – Venkat