API 참조

ExecuteJS에서 사용할 수 있는 모든 Tauri 명령어를 확인하세요.

기본 명령어

execute_js

자바스크립트에 실행을 요청하는 명령어입니다.

import { invoke } from '@tauri-apps/api/core';

const result = await invoke('execute_js', {
  code: 'console.log("Hello, World!");',
});
console.log(result);

매개변수:

  • code (string): 실행할 JavaScript 코드

반환값:

  • JsExecutionResult: 실행 결과 객체

에러 처리

모든 명령어는 Promise를 반환하며, 에러가 발생할 경우 적절한 에러 메시지와 함께 거부됩니다.

try {
  const result = await invoke('execute_js', { code: 'invalid syntax' });
} catch (error) {
  console.error('Execution failed:', error);
}